Sync Upstream Dev #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |