Skip to content

Commit dfa911a

Browse files
committed
Use SYNC_TOKEN PAT so sync can push upstream workflow files
GITHUB_TOKEN is a GitHub Apps installation token and cannot push branches containing .github/workflows/ changes regardless of the permissions block. A classic PAT with repo + workflow scopes is required. Add one as a secret named SYNC_TOKEN.
1 parent 3c5e4b9 commit dfa911a

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

.github/workflows/teal-sync-upstream-release.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name: Sync Upstream Metabase Release
33
# Monitors metabase/metabase for new releases daily and syncs them into master.
44
# - Clean merge: pushed to master automatically.
55
# - Merge conflicts: branch pushed + PR opened for manual resolution.
6+
#
7+
# Requires a secret named SYNC_TOKEN: a classic PAT with repo + workflow scopes.
8+
# GitHub Apps tokens (GITHUB_TOKEN) cannot push branches containing workflow files.
69

710
on:
811
schedule:
@@ -16,17 +19,14 @@ jobs:
1619
permissions:
1720
contents: write
1821
pull-requests: write
19-
workflows: write
2022

2123
steps:
2224
- name: Checkout fork
2325
uses: actions/checkout@v4
2426
with:
2527
ref: master
2628
fetch-depth: 0
27-
# If master has branch protection requiring a PAT, set a SYNC_TOKEN secret
28-
# and replace secrets.GITHUB_TOKEN here and in the GH_TOKEN env vars below.
29-
token: ${{ secrets.GITHUB_TOKEN }}
29+
token: ${{ secrets.SYNC_TOKEN }}
3030

3131
- name: Configure git identity
3232
run: |
@@ -36,7 +36,7 @@ jobs:
3636
- name: Fetch latest upstream release tag
3737
id: upstream
3838
env:
39-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
GH_TOKEN: ${{ secrets.SYNC_TOKEN }}
4040
run: |
4141
TAG=$(gh api repos/metabase/metabase/releases/latest --jq '.tag_name')
4242
if [[ -z "$TAG" || "$TAG" == "null" ]]; then
@@ -103,12 +103,12 @@ jobs:
103103
git checkout master
104104
git merge "$BRANCH" --ff-only
105105
git push origin master
106-
echo "::notice::Synced $TAG to master automatically."
106+
echo "::notice::Synced $TAG to master automatically."
107107
108108
- name: Open conflict-resolution PR
109109
if: steps.status.outputs.result == 'needs-sync' && steps.merge.outputs.outcome == 'conflicts'
110110
env:
111-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
111+
GH_TOKEN: ${{ secrets.SYNC_TOKEN }}
112112
CONFLICTS: ${{ steps.merge.outputs.conflicts }}
113113
run: |
114114
TAG="${{ steps.upstream.outputs.tag }}"
@@ -161,15 +161,15 @@ jobs:
161161
OUTCOME="${{ steps.merge.outputs.outcome }}"
162162
163163
if [[ "$RESULT" == "already-synced" ]]; then
164-
echo "### Already up to date" >> "$GITHUB_STEP_SUMMARY"
164+
echo "### Already up to date" >> "$GITHUB_STEP_SUMMARY"
165165
echo "$TAG is already in master — no action taken." >> "$GITHUB_STEP_SUMMARY"
166166
elif [[ "$RESULT" == "pr-open" ]]; then
167-
echo "### PR already open" >> "$GITHUB_STEP_SUMMARY"
167+
echo "### PR already open" >> "$GITHUB_STEP_SUMMARY"
168168
echo "A sync branch for $TAG already exists. Check open PRs." >> "$GITHUB_STEP_SUMMARY"
169169
elif [[ "$OUTCOME" == "clean" ]]; then
170-
echo "### Synced automatically" >> "$GITHUB_STEP_SUMMARY"
170+
echo "### Synced automatically" >> "$GITHUB_STEP_SUMMARY"
171171
echo "$TAG was merged cleanly into master." >> "$GITHUB_STEP_SUMMARY"
172172
elif [[ "$OUTCOME" == "conflicts" ]]; then
173-
echo "### ⚠️ Conflicts — PR opened" >> "$GITHUB_STEP_SUMMARY"
173+
echo "### Conflicts — PR opened" >> "$GITHUB_STEP_SUMMARY"
174174
echo "$TAG has merge conflicts. A PR has been opened for manual resolution." >> "$GITHUB_STEP_SUMMARY"
175175
fi

0 commit comments

Comments
 (0)