Skip to content

Commit 07f3ffd

Browse files
Require auto-merge and rebase for Dependabot (#49) (#52)
1 parent 79c509e commit 07f3ffd

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

.github/workflows/dependabot-auto-merge.yml

+22-5
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,34 @@ jobs:
6565
6666
auto-merge:
6767
needs: resolve-conflicts
68-
if: github.event.pull_request.user.login == 'dependabot[bot]'
6968
runs-on: ubuntu-latest
7069

7170
steps:
72-
- name: Fetch Dependabot metadata
73-
id: metadata
74-
uses: dependabot/fetch-metadata@v1
71+
- name: Mark auto-merge check for non-Dependabot PRs
72+
if: github.event.pull_request.user.login != 'dependabot[bot]'
73+
run: |
74+
echo "Skipping dependabot-auto-merge for non-Dependabot PRs."
75+
exit 0 # This prevents it from failing on non-Dependabot PRs
76+
77+
- name: Checkout PR branch
78+
if: github.event.pull_request.user.login == 'dependabot[bot]'
79+
uses: actions/checkout@v4
7580
with:
76-
github-token: "${{ secrets.GITHUB_TOKEN }}"
81+
ref: ${{ github.event.pull_request.head.ref }}
82+
fetch-depth: 0
83+
84+
- name: Pull latest changes from PR branch
85+
if: github.event.pull_request.user.login == 'dependabot[bot]'
86+
run: |
87+
git config --global user.name "github-actions[bot]"
88+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
89+
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
90+
git fetch origin ${{ github.event.pull_request.head.ref }}
91+
git rebase origin/${{ github.event.pull_request.head.ref }} || git rebase --abort
92+
git push origin HEAD --force-with-lease
7793
7894
- name: Enable auto-merge for Dependabot PRs
95+
if: github.event.pull_request.user.login == 'dependabot[bot]'
7996
run: gh pr merge --auto --merge "$PR_URL"
8097
env:
8198
PR_URL: ${{ github.event.pull_request.html_url }}

0 commit comments

Comments
 (0)