Skip to content

Commit d6b229b

Browse files
authored
Update auto-merge-to-main.yml
1 parent f326321 commit d6b229b

1 file changed

Lines changed: 29 additions & 30 deletions

File tree

.github/workflows/auto-merge-to-main.yml

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ jobs:
115115
env:
116116
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
117117

118-
# 👇 RESTORED MISSING STEP HERE
119118
- name: Check if already merged
120119
if: steps.check_all.outputs.should_merge == 'true'
121120
id: check_merged
@@ -133,13 +132,9 @@ jobs:
133132
echo "📝 Commit $SHORT_SHA not yet in main. Proceeding with merge."
134133
echo "already_merged=false" >> $GITHUB_OUTPUT
135134
fi
136-
135+
137136
- name: Merge development into main
138137
if: steps.check_all.outputs.should_merge == 'true' && steps.check_merged.outputs.already_merged == 'false'
139-
env:
140-
# Combined env variables here to avoid duplicate key error
141-
TRIGGER_WORKFLOW: ${{ github.event.workflow_run.name }}
142-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
143138
run: |
144139
COMMIT_SHA="${{ steps.check_all.outputs.commit_sha }}"
145140
SHORT_SHA="${{ steps.check_all.outputs.short_sha }}"
@@ -153,14 +148,16 @@ jobs:
153148
# Fetch latest development
154149
git fetch origin development
155150
156-
# Merge the commit
151+
# Merge the commit (this brings all ancestor commits too!)
152+
WORKFLOW_COUNT=$(jq '. | length' runs.json)
153+
157154
if git merge $COMMIT_SHA --no-ff -m "Auto-merge: development → main ($SHORT_SHA)
158155
159-
All CI checks passed for commit $SHORT_SHA.
156+
All CI checks passed for commit $SHORT_SHA.
160157

161-
✅ Workflows completed: $(jq '. | length' runs.json)
162-
📦 Merged by: GitHub Actions
163-
🔗 Triggered by: $TRIGGER_WORKFLOW"; then
158+
✅ Workflows completed: $WORKFLOW_COUNT
159+
📦 Merged by: GitHub Actions
160+
🔗 Triggered by: ${{ github.event.workflow_run.name }}"; then
164161

165162
echo "✅ Merge successful!"
166163

@@ -178,32 +175,34 @@ jobs:
178175
--title "🚨 Auto-merge Failed: Conflict in $SHORT_SHA" \
179176
--body "## Merge Conflict Detected
180177

181-
Commit [$SHORT_SHA](https://github.com/${{ github.repository }}/commit/$COMMIT_SHA) passed all CI tests but has merge conflicts with \`main\`.
178+
Commit [$SHORT_SHA](https://github.com/${{ github.repository }}/commit/$COMMIT_SHA) passed all CI tests but has merge conflicts with main.
182179

183-
**Manual intervention required:**
180+
**Manual intervention required:**
184181

185-
\`\`\`bash
186-
git checkout main
187-
git pull origin main
188-
git merge $COMMIT_SHA
189-
# Resolve conflicts
190-
git commit
191-
git push origin main
192-
\`\`\`
182+
\`\`\`bash
183+
git checkout main
184+
git pull origin main
185+
git merge $COMMIT_SHA
186+
# Resolve conflicts
187+
git commit
188+
git push origin main
189+
\`\`\`
193190

194-
**Or rebase development on main:**
191+
**Or rebase development on main:**
195192

196-
\`\`\`bash
197-
git checkout development
198-
git pull origin development
199-
git rebase origin/main
200-
# Resolve conflicts
201-
git push --force-with-lease origin development
202-
\`\`\`
193+
\`\`\`bash
194+
git checkout development
195+
git pull origin development
196+
git rebase origin/main
197+
# Resolve conflicts
198+
git push --force-with-lease origin development
199+
\`\`\`
203200

204-
Once resolved, this workflow will retry automatically." \
201+
Once resolved, this workflow will retry automatically." \
205202
--label "auto-merge-conflict" \
206203
--label "needs-manual-merge"
207204

208205
exit 1
209206
fi
207+
env:
208+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)