Skip to content

Commit 1ac0cc8

Browse files
committed
feat(workflows): enhance Dependabot PR review process 3
1 parent 0b4e9ea commit 1ac0cc8

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

.github/workflows/dependabot-reviewer.yml

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,47 +7,38 @@ permissions:
77
contents: write
88

99
jobs:
10+
1011
review-dependabot-pr:
1112
runs-on: ubuntu-latest
13+
14+
# Trigger only if the PR is created by Dependabot
1215
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
16+
1317
env:
1418
PR_URL: ${{ github.event.pull_request.html_url }}
1519
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1620

1721
steps:
18-
- name: Check out repository
19-
uses: actions/checkout@v3
20-
with:
21-
token: ${{ secrets.GITHUB_TOKEN }}
22-
22+
# Fetch metadata from Dependabot
2323
- name: Dependabot metadata
2424
id: dependabot-metadata
2525
uses: dependabot/fetch-metadata@v2.1.0
2626

27-
- name: Fetch all branches
28-
run: git fetch --all
29-
30-
- name: Attempt fast-forward merge
31-
run: |
32-
BASE_BRANCH="${{ github.event.pull_request.base.ref }}"
33-
HEAD_BRANCH="${{ github.event.pull_request.head.ref }}"
34-
git checkout $BASE_BRANCH
35-
git merge --ff-only $HEAD_BRANCH || exit 0
36-
env:
37-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38-
27+
# Enable auto-merge for Dependabot PRs
3928
- name: Enable auto-merge for Dependabot PRs
40-
if: ${{ github.event.pull_request.merged == false }}
4129
run: gh pr merge --auto --merge "$PR_URL"
4230

31+
# Approve patch and minor updates
4332
- name: Approve patch and minor updates
4433
if: ${{ steps.dependabot-metadata.outputs.update-type == 'version-update:semver-patch' || steps.dependabot-metadata.outputs.update-type == 'version-update:semver-minor' }}
4534
run: gh pr review $PR_URL --approve -b "I'm **approving** this pull request because it includes a ${{ steps.dependabot-metadata.outputs.update-type }} update"
4635

36+
# Approve major updates of development dependencies
4737
- name: Approve major updates of development dependencies
4838
if: ${{ steps.dependabot-metadata.outputs.update-type == 'version-update:semver-major' && steps.dependabot-metadata.outputs.dependency-type == 'direct:development' }}
4939
run: gh pr review $PR_URL --approve -b "I'm **approving** this pull request because **it includes a major update of a dependency used only in development**"
5040

41+
# Comment on major updates of production dependencies
5142
- name: Comment on major updates of non-development dependencies
5243
if: ${{ steps.dependabot-metadata.outputs.update-type == 'version-update:semver-major' && steps.dependabot-metadata.outputs.dependency-type == 'direct:production' }}
5344
run: |

0 commit comments

Comments
 (0)