Skip to content

chore: release 0.17.0 to production (#723) #23

chore: release 0.17.0 to production (#723)

chore: release 0.17.0 to production (#723) #23

name: Detect staging drift from main
on:
push:
branches:
- main
jobs:
drift-check:
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for drift
id: drift
run: |
git fetch origin staging
COUNT=$(git log --oneline origin/staging..origin/main | wc -l | tr -d ' ')
echo "count=$COUNT" >> "$GITHUB_OUTPUT"
if [ "$COUNT" -gt 0 ]; then
echo "Commits in main not yet in staging:"
git log --oneline origin/staging..origin/main
fi
- name: Open drift issue if needed
if: steps.drift.outputs.count != '0'
uses: actions/github-script@v7
with:
script: |
const count = '${{ steps.drift.outputs.count }}';
const sha = context.sha.slice(0, 8);
// Check for an existing open drift issue to avoid duplicates
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
labels: 'staging-drift',
state: 'open',
});
if (issues.data.length > 0) {
core.info('Drift issue already open: ' + issues.data[0].html_url);
return;
}
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `chore: sync main back into staging (drift after ${sha})`,
body: [
`**${count} commit(s)** in \`main\` are not in \`staging\`'s ancestry after push to main at ${sha}.`,
'',
'This drift will cause conflicts on the next `staging → main` promotion.',
'',
'## Required action',
'1. Create a `chore/sync-main-to-staging` branch from `origin/staging`',
'2. `git merge origin/main -X ours --no-edit` (prefer staging for any conflicts)',
'3. PR the branch into `staging`, merge, redeploy staging',
'4. Close this issue',
'',
'> Auto-opened by the detect-staging-drift workflow.',
].join('\n'),
labels: ['staging-drift'],
});