Skip to content

Commit ccdf365

Browse files
committed
IOPZ-2705 Standardize Dependabot automerging
This commit updates this repo's `dependabot-prs.yml` to match the version in our `base-dependabot-automation` repo.
1 parent 0b8632a commit ccdf365

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

.github/workflows/dependabot-prs.yml

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,30 @@ jobs:
2121
env:
2222
PR_URL: ${{github.event.pull_request.html_url}}
2323
GITHUB_TOKEN: ${{secrets.PANORAMA_BOT_RW_TOKEN}}
24+
- name: Add the Needs QA label to dependabots after any change by someone other than the dependabot bot
25+
# Need to avoid the situation where someone removes the "Needs QA" label and we are adding it back.
26+
if: ${{ github.actor != 'dependabot[bot]' && github.event.action != 'labeled' }}
27+
run: gh pr edit "$PR_URL" --add-label "Needs QA"
28+
env:
29+
PR_URL: ${{github.event.pull_request.html_url}}
30+
GITHUB_TOKEN: ${{secrets.PANORAMA_BOT_RW_TOKEN}}
31+
- name: Fetch Dependabot metadata
32+
if: ${{ github.actor == 'dependabot[bot]' }}
33+
id: dependabot-metadata
34+
uses: dependabot/[email protected]
35+
with:
36+
github-token: "${{ secrets.GITHUB_TOKEN }}"
2437
- name: Approve and merge Dependabot PRs for development dependencies
2538
# Auto-merge the PR if either:
2639
# a) it has the `development-dependencies` label, which we add for certain
2740
# categories of PRs (see `.github/dependabot.yml`), OR
2841
# b) Dependabot has categorized it as a `direct:development` dependency,
29-
# meaning it's in the Gemfile in a `development` or `test` group
30-
#
31-
# Note that we also do nothing when the PR has already had auto-merge
32-
# enabled, to prevent scenarios where this check runs many times (for
33-
# instance, because removing `Needs QA` triggers another run, or because
34-
# other PRs are merging and causing this to rebase and trigger another
35-
# run) and then approves the PR many times, which is confusing and looks
36-
# awkward.
37-
if: ${{ github.actor == 'dependabot[bot]' && !github.event.pull_request.auto_merge }}
38-
run: gh pr merge --auto --merge "$PR_URL" && gh pr review --approve "$PR_URL"
42+
# meaning it's in the Gemfile in a `development` or `test` group, OR
43+
# c) our scripts have flagged the PR as an automergeable dependency (i.e
44+
# a stable dependency with good unit test coverage) that has passed
45+
# the waiting period.
46+
if: ${{ (github.actor == 'dependabot[bot]' || github.actor == 'panorama-bot-r') && steps.unique-committers.outputs.committers == '["dependabot[bot]"]' && (contains(github.event.pull_request.labels.*.name, 'development-dependencies') || steps.dependabot-metadata.outputs.dependency-type == 'direct:development' || contains(github.event.pull_request.labels.*.name, 'automerge-dependencies')) }}
47+
run: gh pr merge --auto --merge "$PR_URL" && gh pr edit "$PR_URL" --remove-label "Needs QA" && gh pr review --approve "$PR_URL"
3948
env:
4049
PR_URL: ${{github.event.pull_request.html_url}}
4150
GITHUB_TOKEN: ${{secrets.PANORAMA_BOT_RW_TOKEN}}

0 commit comments

Comments
 (0)