From 139ce6baad6aad5d09dc6236bb831d80290dd0cf Mon Sep 17 00:00:00 2001 From: MiFaZhan Date: Fri, 30 Oct 2026 11:27:31 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20main/tag=20=E6=8E=A8=E9=80=81=E6=97=B6?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E9=95=9C=E5=83=8F=E5=88=B0=20Gitee?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增 .gitea/workflows/mirror-to-gitee.yml: - 触发:push 到 main、push v* tag、手动 dispatch - 动作:git clone --mirror 源仓 → git push --mirror 到 gitee.com/snowgoat/<同名仓库> - 凭据:组织密钥 SRC_GIT_TOKEN(源仓只读)、GITEE_TOKEN / GITEE_OWNER / GITEE_USER(目标) --- .gitea/workflows/mirror-to-gitee.yml | 48 ++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .gitea/workflows/mirror-to-gitee.yml diff --git a/.gitea/workflows/mirror-to-gitee.yml b/.gitea/workflows/mirror-to-gitee.yml new file mode 100644 index 0000000..49562d3 --- /dev/null +++ b/.gitea/workflows/mirror-to-gitee.yml @@ -0,0 +1,48 @@ +name: mirror-to-gitee + +# 把本仓同步到 Gitee 企业仓 snowgoat/<同名仓库>。 +# 触发:main 分支推送、v* tag 推送,也可手动。 +on: + push: + branches: + - main + tags: + - 'v*' + workflow_dispatch: + +concurrency: + group: mirror-${{ github.ref }} + cancel-in-progress: true + +jobs: + mirror: + runs-on: host + steps: + - name: 同步到 Gitee + env: + SRC_TOKEN: ${{ secrets.SRC_GIT_TOKEN }} + DST_TOKEN: ${{ secrets.GITEE_TOKEN }} + DST_OWNER: ${{ secrets.GITEE_OWNER }} + DST_USER: ${{ secrets.GITEE_USER }} + REPO_NAME: ${{ github.event.repository.name }} + run: | + set -eu + + if [ -z "${REPO_NAME:-}" ]; then + echo "未取到仓库名,退出"; exit 1 + fi + + WORK=$(mktemp -d) + trap 'rm -rf "$WORK"' EXIT + + echo "源:git.5iot.com/iotlcm-public/$REPO_NAME" + echo "目标:gitee.com/$DST_OWNER/$REPO_NAME" + + git clone --mirror "https://jenkins:${SRC_TOKEN}@git.5iot.com/iotlcm-public/${REPO_NAME}.git" "$WORK/repo.git" + + cd "$WORK/repo.git" + echo "本地 ref:$(git for-each-ref --format='%(refname:short)' | tr '\n' ' ')" + + git push --mirror "https://${DST_USER}:${DST_TOKEN}@gitee.com/${DST_OWNER}/${REPO_NAME}.git" + + echo "✅ 已同步到 Gitee"