fix(ci): resolve merge conflict, use PAT-only token for fork sync
This commit is contained in:
commit
11c6f53468
1 changed files with 17 additions and 2 deletions
19
.github/workflows/sync-upstream.yml
vendored
19
.github/workflows/sync-upstream.yml
vendored
|
|
@ -2,6 +2,7 @@ name: Upstream Sync
|
|||
|
||||
permissions:
|
||||
contents: write
|
||||
issues: write
|
||||
|
||||
on:
|
||||
schedule:
|
||||
|
|
@ -19,7 +20,17 @@ jobs:
|
|||
with:
|
||||
ref: master
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.UPSTREAM_TOKEN || secrets.GITHUB_TOKEN }}
|
||||
# Must use a PAT with repo scope — GITHUB_TOKEN cannot push in fork scheduled workflows
|
||||
token: ${{ secrets.UPSTREAM_TOKEN }}
|
||||
|
||||
- name: Check UPSTREAM_TOKEN
|
||||
run: |
|
||||
if [ -z "$UPSTREAM_TOKEN" ]; then
|
||||
echo "::error::UPSTREAM_TOKEN secret is not set. Please add a Personal Access Token with repo scope to your repository secrets."
|
||||
exit 1
|
||||
fi
|
||||
env:
|
||||
UPSTREAM_TOKEN: ${{ secrets.UPSTREAM_TOKEN }}
|
||||
|
||||
- name: Sync upstream changes
|
||||
id: sync
|
||||
|
|
@ -40,6 +51,10 @@ jobs:
|
|||
echo "Upstream: $UPSTREAM"
|
||||
echo "has_changes=true" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# Configure git for the merge commit
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
# Try merge first (preserves both histories)
|
||||
if git merge upstream/master --no-edit; then
|
||||
git push origin master
|
||||
|
|
@ -64,5 +79,5 @@ jobs:
|
|||
labels: ["🚨 Sync Fail"],
|
||||
body: `Due to conflicts or workflow changes in the [alexta69/metube](https://github.com/alexta69/metube) upstream repository, the automatic sync has failed. Please manually sync your fork and resolve any conflicts.
|
||||
|
||||
由于上游仓库 [alexta69/metube](https://github.com/alexta69/metube) 存在冲突或 workflow 变更,自动同步失败。请手动 Sync Fork 并解决冲突。`
|
||||
由于上游仓库 [alexta69/metube](https://github.com/alexta69/metube) 存在冲突或 workflow 变历,自动同步失败。请手动 Sync Fork 并解决冲突。`
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue