|
1 | | -name: Update contributors |
| 1 | +name: 'Update Contributors List' |
| 2 | + |
2 | 3 | on: |
3 | 4 | workflow_dispatch: |
4 | 5 | schedule: |
5 | | - - cron: '0 0 1 * *' |
| 6 | + - cron: 0 4 * * 0 |
6 | 7 |
|
7 | | -jobs: |
8 | | - delete-old-branch: |
9 | | - runs-on: ubuntu-22.04 |
10 | | - continue-on-error: true |
11 | | - steps: |
12 | | - - name: Delete old contributors-update branch |
13 | | - uses: dawidd6/action-delete-branch@v3 |
14 | | - with: |
15 | | - github_token: ${{secrets.GITHUB_TOKEN}} |
16 | | - branches: contributors-update |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + pull-requests: write |
| 11 | + statuses: write |
| 12 | + |
| 13 | +env: |
| 14 | + # Assign commit authorship to official Github Actions bot: |
| 15 | + GIT_USER: github-actions[bot] |
| 16 | + GIT_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com |
17 | 17 |
|
| 18 | +jobs: |
18 | 19 | add-contributors: |
| 20 | + name: 'Add Contributors' |
19 | 21 | runs-on: ubuntu-22.04 |
20 | | - needs: delete-old-branch |
21 | 22 | steps: |
22 | | - - uses: actions/checkout@v3 |
| 23 | + - name: 'Checkout' |
| 24 | + uses: actions/checkout@v3 |
23 | 25 |
|
24 | | - - name: Create contributors-update branch |
25 | | - uses: peterjgrainger/action-create-branch@v2.4.0 |
26 | | - env: |
27 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
28 | | - with: |
29 | | - branch: 'contributors-update' |
30 | | - |
31 | | - - name: Auto-add contributors |
| 26 | + # See https://github.com/marketplace/actions/auto-add-contributors for reference of the action. |
| 27 | + # |
| 28 | + # This action is not well documented, but it does the job for now. We pin the version in order |
| 29 | + # to not have any issues in the future. |
| 30 | + - name: 'Update CONTRIBUTORS.md' |
32 | 31 | uses: BobAnkh/add-contributors@v0.2.2 |
33 | 32 | with: |
34 | | - BRANCH: 'contributors-update' |
35 | | - PULL_REQUEST: 'master' |
36 | | - CONTRIBUTOR: '## Contributors' |
37 | | - COLUMN_PER_ROW: '6' |
38 | 33 | ACCESS_TOKEN: ${{secrets.GITHUB_TOKEN}} |
39 | | - IMG_WIDTH: '100' |
40 | | - FONT_SIZE: '14' |
41 | | - PATH: '/CONTRIBUTORS.md' |
42 | | - COMMIT_MESSAGE: 'docs(CONTRIBUTORS): update contributors' |
43 | | - AVATAR_SHAPE: 'round' |
| 34 | + COMMIT_MESSAGE: 'docs: update `CONTRIBUTORS.md`' |
| 35 | + PATH: /CONTRIBUTORS.md |
| 36 | + CONTRIBUTOR: '## Contributors' |
| 37 | + COLUMN_PER_ROW: 6 |
| 38 | + IMG_WIDTH: 100 |
| 39 | + FONT_SIZE: 14 |
| 40 | + AVATAR_SHAPE: round |
| 41 | + |
| 42 | + # See https://github.com/marketplace/actions/create-pull-request for reference of the action. |
| 43 | + - name: 'Create Pull Request' |
| 44 | + uses: peter-evans/create-pull-request@v5.0.0 |
| 45 | + id: create-pr |
| 46 | + with: |
| 47 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 48 | + branch: contributors-update |
| 49 | + title: 'docs: update `CONTRIBUTORS.md`' |
| 50 | + commit-message: 'docs: update `CONTRIBUTORS.md`' |
| 51 | + delete-branch: true |
| 52 | + committer: ${{ env.GIT_USER }} <${{ env.GIT_EMAIL }}> |
| 53 | + author: ${{ env.GIT_USER }} <${{ env.GIT_EMAIL }}> |
| 54 | + signoff: true |
| 55 | + body: | |
| 56 | + Updated `CONTRIBUTORS.md` via the CI workflow: [`contributors.yml`][workflow]. |
44 | 57 |
|
45 | | - # This workflow will not trigger a `pull_request` event without a PAT. |
46 | | - # The lint workflow is not important for this type of PR, skip it and pretend it was successful: |
47 | | - - name: 'Get the latest commit hash from the contributors-update branch' |
48 | | - id: commit-data |
49 | | - run: | |
50 | | - git pull |
51 | | - git checkout contributors-update |
52 | | - echo "head_sha=$(git rev-parse contributors-update)" >>"${GITHUB_OUTPUT}" |
| 58 | + [workflow]: https://github.com/docker-mailserver/docker-mailserver/blob/master/.github/workflows/contributors.yml |
53 | 59 |
|
54 | | - - name: 'Commit Status: Set Lint status to success (skipped)' |
| 60 | + # See https://github.com/marketplace/actions/set-commit-status for reference of the action. |
| 61 | + # |
| 62 | + # GH Actions are limited when it comes to actions triggering other actions. Hence, |
| 63 | + # this whole workflow will not trigger a `pull_request` event without a PAT. The lint |
| 64 | + # workflow, which is required due to branch protection, is not important for this type |
| 65 | + # of PR, so we skip it and pretend it was successful. |
| 66 | + - name: 'Set Status for Linting Actions to Success (Skipped)' |
55 | 67 | uses: myrotvorets/set-commit-status-action@1.1.6 |
| 68 | + continue-on-error: true |
56 | 69 | with: |
57 | 70 | token: ${{ secrets.GITHUB_TOKEN }} |
58 | 71 | # Skipped workflows are still assigned a "success" status: |
59 | 72 | status: success |
60 | 73 | # This should be the correct commit SHA on the contributors-update branch: |
61 | | - sha: ${{ steps.commit-data.outputs.head_sha }} |
| 74 | + sha: ${{ steps.create-pr.outputs.pull-request-head-sha }} |
62 | 75 | # Name of status check to add/update: |
63 | | - context: 'lint' |
| 76 | + context: lint |
64 | 77 | # Optional message/note we can inline to the right of the context name in the UI: |
65 | | - description: "Lint skipped. Not relevant." |
| 78 | + description: Lint skipped. Not relevant. |
0 commit comments