Files
soul/开发文档/.github/workflows/sync_from_coding.yml
2026-01-09 11:58:08 +08:00

37 lines
1.4 KiB
YAML

name: Sync from Coding
on:
schedule:
- cron: '0 */2 * * *' # 每2小时执行一次
workflow_dispatch: # 允许手动触发
jobs:
sync:
runs-on: ubuntu-latest
permissions:
contents: write # 确保此行存在,赋予工作流写入仓库内容的权限,这是解决 403 权限问题的基础
steps:
- name: 检出 GitHub 仓库
uses: actions/checkout@v4
with:
ref: develop # 明确检出 develop 分支,确保在正确的分支上操作
- name: 配置 Git 用户并合并 Coding 代码到 GitHub
run: |
# 配置 Git 用户信息
git config user.name "zhiqun@qq.com"
git config user.email "zhiqun@qq.com"
# 添加 Coding 仓库为一个新的远程源
git remote add coding-origin https://${{ secrets.CODING_USERNAME }}:${{ secrets.CODING_TOKEN }}@e.coding.net/g-xtcy5189/cunkebao/cunkebao_v3.git
# 从 Coding 远程仓库获取 develop 分支的最新信息
git fetch coding-origin develop
# 合并 Coding 的 develop 分支到本地的 develop 分支
# --allow-unrelated-histories 允许合并两个没有共同历史的分支
git merge --no-ff --allow-unrelated-histories coding-origin/develop
# 将合并后的本地 develop 分支推送到 GitHub 的 develop 分支
git push origin develop