Skip to content

Commit f0d4012

Browse files
chore(actions): auto merge action for dependabot updated
Updated auto merge action for dependabot.
1 parent a4796c9 commit f0d4012

File tree

1 file changed

+16
-26
lines changed

1 file changed

+16
-26
lines changed

.github/workflows/auto-merge.yml

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,27 @@ name: Auto-Merge Dependabot PRs
22

33
on:
44
pull_request:
5-
types:
6-
- opened
7-
- synchronize
8-
- reopened
95
branches:
10-
- master # or your default branch
6+
- master
7+
8+
permissions:
9+
pull-requests: write
10+
contents: write
1111

1212
jobs:
1313
auto-merge:
14-
if: github.actor == 'dependabot[bot]'
1514
runs-on: ubuntu-latest
15+
if: github.actor == 'dependabot[bot]'
1616
steps:
17-
- name: Checkout code
18-
uses: actions/checkout@v3
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
1919

20-
- name: Auto-merge Dependabot PR
21-
uses: actions/github-script@v6
22-
with:
23-
script: |
24-
const { data: pr } = await github.rest.pulls.get({
25-
owner: context.repo.owner,
26-
repo: context.repo.repo,
27-
pull_number: context.payload.pull_request.number,
28-
});
20+
- name: Authenticate with GitHub CLI
21+
env:
22+
GH_TOKEN: ${{ secrets.PAT }}
23+
run: gh auth login --with-token
2924

30-
// Check if the PR is from Dependabot and all checks are passing
31-
if (pr.user.login === 'dependabot[bot]' && pr.mergeable_state === 'clean') {
32-
await github.rest.pulls.merge({
33-
owner: context.repo.owner,
34-
repo: context.repo.repo,
35-
pull_number: context.payload.pull_request.number,
36-
merge_method: 'squash', // or 'merge' or 'rebase'
37-
});
38-
}
25+
- name: Merge Dependabot PR
26+
env:
27+
GH_TOKEN: ${{ secrets.PAT }}
28+
run: gh pr merge ${{ github.event.pull_request.number }} --squash --delete-branch

0 commit comments

Comments
 (0)