From db58885ecfbe916ffb8feaa2f79473b1eb598830 Mon Sep 17 00:00:00 2001 From: xiaowang <2161656029@qq.com> Date: Mon, 23 Nov 2026 16:51:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=20sync-to-gitea.yml=20=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E8=B0=83=E7=94=A8=20ci-config=20=E5=8F=AF=E5=A4=8D?= =?UTF-8?q?=E7=94=A8=E5=B7=A5=E4=BD=9C=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 原 71 行完整实现迁移到 ci-config 分支 - dev 分支只保留 13 行调用入口 --- .github/workflows/sync-to-gitea.yml | 61 +++-------------------------- 1 file changed, 5 insertions(+), 56 deletions(-) diff --git a/.github/workflows/sync-to-gitea.yml b/.github/workflows/sync-to-gitea.yml index 4366471a..92be7802 100644 --- a/.github/workflows/sync-to-gitea.yml +++ b/.github/workflows/sync-to-gitea.yml @@ -1,4 +1,3 @@ - name: Sync GitHub dev to Gitea on: @@ -7,65 +6,15 @@ on: - dev paths-ignore: - ".github/workflows/sync-to-gitea.yml" + workflow_dispatch: permissions: contents: read -concurrency: - group: github-to-gitea-dev - cancel-in-progress: false - jobs: sync: - name: Push GitHub dev to Gitea dev - runs-on: ubuntu-latest - - steps: - - name: Checkout full history - uses: actions/checkout@v4 - with: - ref: dev - fetch-depth: 0 - - - name: Validate and push to Gitea - shell: bash - env: - GITEA_USERNAME: ${{ secrets.GITEA_USERNAME }} - GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} - GITHUB_SHA: ${{ github.sha }} - run: | - set -euo pipefail - - if [[ -z "$GITEA_USERNAME" || -z "$GITEA_TOKEN" ]]; then - echo "::error::Missing Gitea credentials." - exit 1 - fi - - AUTH="$(printf '%s' "$GITEA_USERNAME:$GITEA_TOKEN" | base64 -w 0)" - - git remote add gitea https://code.yunail.art/xiaowang/JayuCloud.git - - git -c http.extraheader="AUTHORIZATION: basic $AUTH" \ - fetch gitea refs/heads/dev:refs/remotes/gitea/dev - - GITEA_SHA="$(git rev-parse refs/remotes/gitea/dev)" - - echo "GitHub commit: $GITHUB_SHA" - echo "Gitea commit: $GITEA_SHA" - - if [[ "$GITEA_SHA" == "$GITHUB_SHA" ]]; then - echo "Both repositories are already synchronized." - exit 0 - fi - - if ! git merge-base --is-ancestor "$GITEA_SHA" "$GITHUB_SHA"; then - echo "::error::Gitea dev has diverged from or advanced beyond GitHub dev." - echo "::error::Refusing to overwrite Gitea." - exit 1 - fi - - git -c http.extraheader="AUTHORIZATION: basic $AUTH" \ - push gitea "$GITHUB_SHA:refs/heads/dev" - - echo "Successfully synchronized GitHub dev to Gitea dev." + uses: xiaowang2219/jayucloud/.github/workflows/reusable-sync-dev-to-gitea.yml@ci-config + secrets: + GITEA_USERNAME: ${{ secrets.GITEA_USERNAME }} + GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}