@@ -4,15 +4,14 @@ name: Dependabot auto-merge
44on : pull_request
55
66permissions :
7- pull-requests : write
8- contents : write
7+ contents : read
98
109jobs :
1110 dependabot :
1211 runs-on : ubuntu-latest
1312 # Checking the actor will prevent your Action run failing on non-Dependabot
1413 # PRs but also ensures that it only does work for Dependabot PRs.
15- if : ${{ github.actor == 'dependabot[bot]' }}
14+ if : github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == github.event.pull_request.head.repo.full_name
1615 steps :
1716 # This first step will fail if there's no metadata and so the approval
1817 # will not occur.
@@ -27,20 +26,24 @@ jobs:
2726 if : ${{ steps.meta.outputs.update-type == null || steps.meta.outputs.update-type == 'version-update:semver-patch' || (!startsWith(steps.meta.outputs.previous-version, '0.') && steps.meta.outputs.update-type == 'version-update:semver-minor') }}
2827 uses : actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
2928 with :
30- app -id : ${{ secrets.APP_ID }}
29+ client -id : ${{ vars.GH_APP_CLIENT_ID }}
3130 private-key : ${{ secrets.GH_APP_PRIVATE_KEY }}
31+ permission-pull-requests : write
32+ permission-contents : write
3233
3334 # Here the PR gets approved.
3435 - name : Approve a PR
3536 if : ${{ steps.meta.outputs.update-type == null || steps.meta.outputs.update-type == 'version-update:semver-patch' || (!startsWith(steps.meta.outputs.previous-version, '0.') && steps.meta.outputs.update-type == 'version-update:semver-minor') }}
36- run : gh pr review --approve "${{ github.event.pull_request.html_url } }"
37+ run : gh pr review --approve "${GITHUB_EVENT_PULL_REQUEST_HTML_URL }"
3738 env :
3839 GITHUB_TOKEN : ${{ steps.app-token.outputs.token }}
40+ GITHUB_EVENT_PULL_REQUEST_HTML_URL : ${{ github.event.pull_request.html_url }}
3941
4042 # Finally, this sets the PR to allow auto-merging for patch and minor
4143 # updates if all checks pass
4244 - name : Enable auto-merge for Dependabot PRs
4345 if : ${{ steps.meta.outputs.update-type == null || steps.meta.outputs.update-type == 'version-update:semver-patch' || (!startsWith(steps.meta.outputs.previous-version, '0.') && steps.meta.outputs.update-type == 'version-update:semver-minor') }}
44- run : gh pr merge --auto --squash "${{ github.event.pull_request.html_url } }"
46+ run : gh pr merge --auto --squash "${GITHUB_EVENT_PULL_REQUEST_HTML_URL }"
4547 env :
46- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
48+ GITHUB_TOKEN : ${{ steps.app-token.outputs.token }}
49+ GITHUB_EVENT_PULL_REQUEST_HTML_URL : ${{ github.event.pull_request.html_url }}
0 commit comments