Skip to content

Commit 5160317

Browse files
authored
Auto-approve dependabot changes (#173)
1 parent 3bfa64c commit 5160317

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

.github/workflows/ack.yml

+21-10
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
permissions:
1919
checks: write
2020
contents: write # needed to update release
21-
pull-requests: write
21+
pull-requests: write # pr approval and merge
2222
steps:
2323
- name: Checkout
2424
uses: actions/checkout@v4
@@ -72,13 +72,24 @@ jobs:
7272
# labeled: skip-changelog
7373
# label-operator: NOT
7474

75-
# - name: Auto-approve pull-requests made by approved bots
76-
# # https://github.com/marketplace/actions/auto-approve
77-
# if: contains(fromJson('["dependabot[bot]", "pre-commit-ci[bot]"]'), github.actor)
78-
# uses: hmarr/auto-approve-action@v3
75+
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#approve-a-pull-request
76+
- name: Dependabot metadata
77+
if: github.actor == 'dependabot[bot]'
78+
id: metadata
79+
uses: dependabot/fetch-metadata@v1
80+
with:
81+
github-token: "${{ secrets.GITHUB_TOKEN }}"
82+
83+
- name: Enable auto-merge for safe bots PRs
84+
if: contains(fromJson('["dependabot[bot]", "pre-commit-ci[bot]"]'), github.actor)
85+
run: gh pr merge --auto --merge "$PR_URL"
86+
env:
87+
PR_URL: ${{github.event.pull_request.html_url}}
88+
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
7989

80-
# - name: Enable auto-merge on changes made by approved bots
81-
# if: contains(fromJson('["dependabot[bot]", "pre-commit-ci[bot]"]'), github.actor)
82-
# uses: alexwilson/enable-github-automerge-action@main
83-
# with:
84-
# github-token: "${{ secrets.GITHUB_TOKEN }}"
90+
- name: Approve a PR
91+
if: contains(fromJson('["dependabot[bot]", "pre-commit-ci[bot]"]'), github.actor)
92+
run: gh pr review --approve "$PR_URL"
93+
env:
94+
PR_URL: ${{github.event.pull_request.html_url}}
95+
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}

0 commit comments

Comments
 (0)