Files
iotlcm/.gitea/workflows/mirror-to-gitee.yml
T
MiFaZhan 27ce9df7a5 ci: main/tag 推送时自动镜像到 Gitee
新增 .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(目标)
2026-10-30 11:27:32 +08:00

49 lines
1.3 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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"