carrot/.github/workflows/sync-to-gitea.yml
2024-12-07 17:17:33 +08:00

36 lines
1.0 KiB
YAML

name: Sync all branches to Gitea
on:
push:
branches:
- '*' # 监听所有分支的变化
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout GitHub repository
uses: actions/checkout@v3
- name: Set up Git
uses: actions/setup-git@v2
with:
git_user_name: 'Your Name'
git_user_email: 'your-email@example.com'
- name: Push all branches to Gitea
env:
GITEA_URL: 'http://124.220.61.41:5000' # 你的Gitea地址
GITEA_REPO: 'zhudongjer/openpilot' # Gitea上的仓库名
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} # GitHub Secrets中配置的Gitea访问令牌
run: |
# 获取所有的远程分支
git fetch --all
# 遍历每一个分支并推送到Gitea
for branch in $(git branch -r | grep -v '\->'); do
git checkout --track $branch
git push https://your_gitea_user:${{ secrets.GITEA_TOKEN }}@${GITEA_URL}/api/v1/repos/${GITEA_REPO}/push HEAD:$branch
done