From 4a9860a25c4105ad2e553e42feb5d51021df2c80 Mon Sep 17 00:00:00 2001 From: ayi <2294931964@qq.com> Date: Fri, 28 Nov 2025 19:57:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BB=A3=E7=A0=81=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E9=85=8D=E7=BD=AEpush2github.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/push2github.yml | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .gitea/workflows/push2github.yml diff --git a/.gitea/workflows/push2github.yml b/.gitea/workflows/push2github.yml new file mode 100644 index 0000000..f0da818 --- /dev/null +++ b/.gitea/workflows/push2github.yml @@ -0,0 +1,36 @@ +name: Sync All Branches to GitHub + +on: + push: + branches: [ '*' ] # 监听所有分支的推送事件 + +jobs: + sync: + runs-on: sync + steps: + - name: Checkout code (Git CLI) + run: | + # 克隆 Gitea 仓库 + git clone ${{ github.server_url }}/${{ github.repository }}.git . + # 切换到当前推送的分支 + git checkout ${{ github.ref }} + + - name: Set up Git identity + run: | + # 配置 Git 用户信息 + git config --global user.name "ayi" + git config --global user.email "2294931964@qq.com" + + - name: Add GitHub remote repository + run: | + # 添加 GitHub 远程仓库,使用令牌进行身份验证 + git remote add github https://${{ secrets.GIT_HUB_TOKEN }}@github.com/xing-jiayi/xiaoyishu.git + + - name: Push current branch to GitHub + run: | + # 获取当前推送的分支名(兼容 refs/heads/ 前缀) + CURRENT_BRANCH="${GITHUB_REF#refs/heads/}" + # 拉取 GitHub 对应分支的最新更改,允许无关历史(防止冲突) + git pull github "${CURRENT_BRANCH}" --rebase --allow-unrelated-histories || true + # 推送当前分支到 GitHub 对应分支 + git push github "${CURRENT_BRANCH}" --force-with-lease # 安全强制推送(避免覆盖他人提交) \ No newline at end of file