Skip to content

Commit 04cae15

Browse files
authored
fix(ci): authenticate SDK back-sync pushes (#4)
1 parent 68023fb commit 04cae15

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

.github/workflows/stlc-sync.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ jobs:
3838
uses: actions/checkout@v6
3939
with:
4040
fetch-depth: 0
41+
persist-credentials: false
4142

4243
- name: Fetch production main
4344
env:
@@ -70,13 +71,21 @@ jobs:
7071
7172
- name: Sync production to staging (fast-forward)
7273
if: steps.diff.outputs.behind == 'true'
74+
env:
75+
PRODUCTION_REPO_TOKEN: ${{ secrets.PRODUCTION_REPO_TOKEN }}
7376
run: |
7477
# Refuse unless staging is an ancestor of production: otherwise the
7578
# trunks have forked and a fast-forward would be unsafe.
7679
if ! git merge-base --is-ancestor origin/main production/main; then
7780
echo "::error title=Back-sync blocked::staging main is not an ancestor of production/main."
7881
exit 1
7982
fi
83+
if [ -z "${PRODUCTION_REPO_TOKEN:-}" ]; then
84+
echo "::error title=Back-sync blocked::PRODUCTION_REPO_TOKEN is required to update staging main."
85+
exit 1
86+
fi
87+
git remote set-url origin \
88+
"https://x-access-token:${PRODUCTION_REPO_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
8089
git push origin production/main:refs/heads/main
8190
echo "Fast-forwarded staging/main to production/main."
8291

0 commit comments

Comments
 (0)