Skip to content

Commit ac10064

Browse files
Copilothotlong
andcommitted
Fix workflows based on code review feedback
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent abf1695 commit ac10064

2 files changed

Lines changed: 6 additions & 53 deletions

File tree

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

Lines changed: 5 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
name: Auto-merge Dependabot PRs
22

3+
# This workflow demonstrates enabling auto-merge for Dependabot PRs.
4+
# GitHub's auto-merge will handle the actual merge, and if configured
5+
# with the CI script approach in the release/CI workflows, lockfile
6+
# conflicts will be automatically resolved.
7+
38
'on':
49
pull_request:
510
types: [opened, synchronize, reopened]
@@ -15,58 +20,7 @@ jobs:
1520
if: github.actor == 'dependabot[bot]'
1621

1722
steps:
18-
- name: Checkout PR
19-
uses: actions/checkout@v4
20-
with:
21-
ref: ${{ github.event.pull_request.head.ref }}
22-
fetch-depth: 0
23-
24-
- uses: pnpm/action-setup@v3
25-
with:
26-
version: 10
27-
28-
- name: Setup Node.js
29-
uses: actions/setup-node@v4
30-
with:
31-
node-version: 20
32-
cache: 'pnpm'
33-
34-
- name: Auto Merge with Lockfile Fix
35-
run: |
36-
# --- Step 1: Configure temporary merge driver ---
37-
# Define a merge driver that runs pnpm install
38-
git config merge.pnpm-merge.name "pnpm-lock.yaml merge driver"
39-
git config merge.pnpm-merge.driver \
40-
"pnpm install --no-frozen-lockfile"
41-
42-
# --- Step 2: Bind the strategy (key step) ---
43-
# Tell Git: for pnpm-lock.yaml, use the pnpm-merge driver
44-
# .git/info/attributes only affects CI, doesn't dirty codebase
45-
echo "pnpm-lock.yaml merge=pnpm-merge" >> .git/info/attributes
46-
47-
# --- Step 3: Fetch and merge as usual ---
48-
# If lock file conflicts, Git auto-resolves without errors
49-
git fetch origin main
50-
git merge origin/main --no-edit || {
51-
echo "Merge failed, checking if it's a lockfile conflict..."
52-
# If merge failed, check if pnpm-lock.yaml is in conflict
53-
if git status | grep -q "pnpm-lock.yaml"; then
54-
echo "Detected pnpm-lock.yaml conflict, regenerating..."
55-
# The merge driver should have already run pnpm install
56-
# Add the regenerated lockfile
57-
git add pnpm-lock.yaml
58-
git commit -m "chore: regenerate pnpm-lock.yaml"
59-
else
60-
echo "Merge conflict is not related to lockfile"
61-
exit 1
62-
fi
63-
}
64-
65-
# Push the merged changes
66-
git push origin ${{ github.event.pull_request.head.ref }}
67-
6823
- name: Enable auto-merge
69-
if: success()
7024
run: |
7125
gh pr merge --auto --squash \
7226
"${{ github.event.pull_request.number }}"

.github/workflows/merge-with-lockfile-fix.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ jobs:
6969
# --- Step 3: Merge as usual ---
7070
# If lock file conflicts, Git auto-resolves without errors
7171
git fetch origin ${{ github.event.inputs.source_branch }}
72-
git merge origin/${{ github.event.inputs.source_branch }} \
73-
--no-edit
72+
git merge origin/${{ github.event.inputs.source_branch }} --no-edit
7473
7574
# Push the merged changes
7675
git push origin ${{ github.event.inputs.target_branch }}

0 commit comments

Comments
 (0)