|
| 1 | +name: Automatically Update Dependencies |
| 2 | + |
| 3 | +# `pull_request_target` grants access to secrets and runs in the scope of the *destination* branch. |
| 4 | +# Specifically we listen for the labelled event. |
| 5 | +on: |
| 6 | + pull_request_target: |
| 7 | + types: |
| 8 | + # Dependabot will label the PR |
| 9 | + - labeled |
| 10 | + # Dependabot has rebased the PR |
| 11 | + - synchronize |
| 12 | + |
| 13 | +permissions: |
| 14 | + contents: read |
| 15 | + |
| 16 | +jobs: |
| 17 | + enable-dependabot-automerge: |
| 18 | + name: Enable auto-merge for Dependabot PRs |
| 19 | + runs-on: ubuntu-latest |
| 20 | + permissions: |
| 21 | + # enable-automerge is a graphql query, not REST, so isn't documented, |
| 22 | + # except in a mention in |
| 23 | + # https://github.blog/changelog/2021-02-04-pull-request-auto-merge-is-now-generally-available/ |
| 24 | + # which says "can only be enabled by users with permissino to merge"; the |
| 25 | + # REST documentation says you need contents: write to perform a merge. |
| 26 | + # https://github.community/t/what-permission-does-a-github-action-need-to-call-graphql-enablepullrequestautomerge/197708 |
| 27 | + # says this is it |
| 28 | + contents: write |
| 29 | + # Specifically check the creator of the pull-request, not the actor. |
| 30 | + if: github.event.pull_request.user.login == 'dependabot[bot]' && contains(github.event.pull_request.labels.*.name, 'dependencies') |
| 31 | + |
| 32 | + steps: |
| 33 | + - name: Enable GitHub Auto-Merge |
| 34 | + # Reference by commit SHA as it is an immutable reference to a |
| 35 | + # known, "trusted" version of this 3rd party code. |
| 36 | + uses: alexwilson/enable-github-automerge-action@56e3117d1ae1540309dc8f7a9f2825bc3c5f06ff |
| 37 | + with: |
| 38 | + github-token: "${{ secrets.GITHUB_TOKEN }}" |
| 39 | + |
| 40 | + approve-dependabot: |
| 41 | + needs: enable-dependabot-automerge |
| 42 | + runs-on: ubuntu-latest |
| 43 | + permissions: |
| 44 | + # https://github.com/hmarr/auto-approve-action/issues/183 says |
| 45 | + # auto-approve-action requires write on pull-requests |
| 46 | + pull-requests: write |
| 47 | + # Specifically check the creator of the pull-request, not the actor. |
| 48 | + if: github.event.pull_request.user.login == 'dependabot[bot]' && contains(github.event.pull_request.labels.*.name, 'dependencies') |
| 49 | + steps: |
| 50 | + - name: Approve dependabot PRs |
| 51 | + # Reference by commit SHA as it is an immutable reference to a |
| 52 | + # known, "trusted" version of this 3rd party code. |
| 53 | + uses: hmarr/auto-approve-action@8f929096a962e83ccdfa8afcf855f39f12d4dac7 |
| 54 | + with: |
| 55 | + github-token: "${{ secrets.GITHUB_TOKEN }}" |
| 56 | +# EOF |
0 commit comments