Skip to content

Sync Upstream Dev

Sync Upstream Dev #2

name: Sync Upstream Dev
on:
workflow_dispatch:
permissions:
contents: write
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Check upstream dev branch existence
id: check
run: |
git remote add upstream https://github.com/cc004/autopcr.git
if [ -z "$(git ls-remote --heads upstream dev)" ]; then
echo "::notice::上游 cc004/autopcr 无 dev 分支(可能已合并到 main 并删除)。请走 main 构建。"
echo "has_dev=false" >> "$GITHUB_OUTPUT"
else
echo "has_dev=true" >> "$GITHUB_OUTPUT"
fi
- name: Sync upstream dev to origin/upstream-dev
if: steps.check.outputs.has_dev == 'true'
run: |
git fetch upstream dev
# 纯镜像:origin/upstream-dev 不保留自有 commit,--force 统一处理 ff/分叉/上游重建三种情况
git push origin upstream/dev:refs/heads/upstream-dev --force