Skip to content

Add workflow to keep maintenance in sync with main #1

Add workflow to keep maintenance in sync with main

Add workflow to keep maintenance in sync with main #1

name: Sync maintenance with main
# Merges main into maintenance on every push to main, so maintenance never falls behind regardless of how a change landed on main.
on:
push:
branches: [main]
permissions:
contents: write
issues: write
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
ref: maintenance
fetch-depth: 0
- name: Merge main into maintenance
id: merge
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git fetch origin main
if git merge origin/main --no-edit; then
git push origin maintenance
else
git merge --abort
echo "conflict=true" >> "$GITHUB_OUTPUT"
exit 1
fi
- name: Open an issue on conflict
if: failure() && steps.merge.outputs.conflict == 'true'
uses: actions/github-script@v8
with:
script: |
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `maintenance is out of sync with main (${context.sha.slice(0, 7)})`,
body: `Merging \`main\` into \`maintenance\` hit a conflict and needs to be resolved by hand:\n\n\`\`\`\ngit checkout maintenance\ngit merge origin/main\n# resolve conflicts\ngit push origin maintenance\n\`\`\``,
});