Skip to content

Commit 78f6945

Browse files
authored
Add a better workflow for automerging dependabot updates (#52)
1 parent 7f4a89b commit 78f6945

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,3 @@ jobs:
5454
else
5555
echo "All jobs completed successfully"
5656
fi
57-
58-
dependabot:
59-
needs:
60-
- all
61-
uses: ./.github/workflows/dependabot.yml

.github/workflows/dependabot.yml

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
1-
name: Automatic Actions for Dependabot PRs
1+
name: dependabot
2+
23
on:
3-
workflow_call:
4+
push:
5+
branches:
6+
- 'dependabot/**'
47

58
permissions:
6-
contents: write
79
pull-requests: write
10+
contents: write
811

912
jobs:
1013
approve-and-merge:
1114
runs-on: ubuntu-latest
12-
if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'spack/spack-distroless'
15+
if: ${{ github.actor == 'dependabot[bot]' && github.repository == 'spack/spack-distroless'}}
1316
steps:
14-
- name: Dependabot metadata
15-
id: metadata
16-
uses: dependabot/fetch-metadata@d7267f607e9d3fb96fc2fbe83e0af444713e90b7
17-
with:
18-
github-token: "${{ secrets.GITHUB_TOKEN }}"
17+
- name: Get PR associated with Branch
18+
id: branch
19+
run: echo "url=$(gh pr list --head ${GITHUB_REF##*/} --json url --template '{{range .}}{{.url}}{{end}}')\n" >> "$GITHUB_OUTPUT"
20+
env:
21+
GITHUB_REF: ${{ github.ref_name }}
1922

20-
- name: Approve Dependabot PRs
23+
- name: Auto Approve Dependabot PRs
2124
run: gh pr review --approve "$PR_URL"
2225
env:
23-
PR_URL: ${{github.event.pull_request.html_url}}
24-
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
26+
PR_URL: ${{ steps.branch.outputs.url }}
27+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2528

2629
- name: Enable auto-merge for Dependabot PRs
27-
run: gh pr merge --auto --merge "$PR_URL"
30+
run: gh pr merge --auto --squash "$PR_URL"
2831
env:
29-
PR_URL: ${{github.event.pull_request.html_url}}
30-
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
32+
PR_URL: ${{ steps.branch.outputs.url }}
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)