Skip to content

Commit 956ffd7

Browse files
authored
Fix metadata update stale checkout (#19222)
1 parent a105817 commit 956ffd7

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

.github/workflows/metadata-update.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,18 @@ jobs:
101101
run: |
102102
BRANCH_NAME="${{ steps.findbranch.outputs.branch }}"
103103
git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}.git"
104-
git commit -m "chore: update instrumentation list [automated]" || echo "No changes to commit."
104+
git commit -m "chore: update instrumentation list [automated]"
105+
# Metadata collection can run for hours, allowing workflow files on main to change after
106+
# checkout. GitHub then rejects pushing the stale branch without workflows: write, even
107+
# though the generated commit only changes docs/instrumentation-list.yaml. Merge instead
108+
# of rebase so that commit remains tied to its source snapshot while the pushed branch
109+
# contains the current workflow files.
110+
git fetch origin main
111+
if ! git merge --no-edit origin/main; then
112+
echo "::error::Failed to merge the latest origin/main into the generated metadata commit."
113+
git merge --abort
114+
exit 1
115+
fi
105116
git push --force origin "$BRANCH_NAME"
106117
git remote set-url origin "https://github.com/${{ github.repository }}.git"
107118

0 commit comments

Comments
 (0)