Skip to content

Commit 0ea0e36

Browse files
committed
chore(github-actions): update auto-merge workflow for Dependabot PRs
- Adjusted conditions to trigger auto-merge only for Dependabot. - Added steps to fetch Dependabot metadata and enable auto-merge for minor and patch updates. - Updated GitHub token usage for improved security.
1 parent cb360b0 commit 0ea0e36

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

.github/workflows/auto-merge.yml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
on:
22
pull_request_target:
3-
types: [labeled]
43

54
name: Dependabot auto-merge
65
jobs:
76
auto-merge:
87
name: Auto-merge dependabot PRs for minor and patch updates
98
runs-on: ubuntu-latest
10-
if: |
11-
contains( github.event.pull_request.labels.*.name, 'dependencies' )
12-
&& ! contains( github.event.pull_request.labels.*.name, '[Status] Approved' )
9+
if: github.actor == 'dependabot[bot]'
10+
permissions:
11+
contents: write
12+
pull-requests: write
1313
steps:
14-
- uses: actions/checkout@v2
15-
- uses: ahmadnassri/action-dependabot-auto-merge@v2
14+
- name: Fetch Dependabot metadata
15+
id: metadata
16+
uses: dependabot/fetch-metadata@v2
1617
with:
17-
target: minor # includes patch updates.
18-
github-token: ${{ secrets.DEPENDABOT_TOKEN }}
18+
github-token: "${{ secrets.GITHUB_TOKEN }}"
19+
20+
- name: Enable auto-merge for minor and patch updates
21+
if: steps.metadata.outputs.update-type == 'version-update:semver-minor' || steps.metadata.outputs.update-type == 'version-update:semver-patch'
22+
run: gh pr merge --auto --squash "$PR_URL"
23+
env:
24+
PR_URL: ${{ github.event.pull_request.html_url }}
25+
GH_TOKEN: ${{ secrets.DEPENDABOT_TOKEN }}

0 commit comments

Comments
 (0)