Skip to content

Gitee repos mirror periodic sync job #53

Gitee repos mirror periodic sync job

Gitee repos mirror periodic sync job #53

########################################
# 用法:
# 1、创建SSH公、私钥,在Linux命令行下执行命令: ssh-keygen -t ed25519 -C "Gitee SSH Key" , 一路回车得到秘钥文件: ~/.ssh/id_ed25519 、~/.ssh/id_ed25519.pub。
# 2、在Github上添加SSH公钥(~/.ssh/id_ed25519.pub文件内容),链接:https://github.com/settings/keys 。
# 3、在Github中创建私人令牌, 链接:https://github.com/settings/tokens 。
# 4、在Gitee中添加SSH公钥(~/.ssh/id_ed25519.pub文件内容),链接:https://gitee.com/profile/sshkeys 。
# 5、在Gitee中创建私人令牌, 链接:https://gitee.com/profile/personal_access_tokens 。
# 6、在Github上创建项目 gateway-proxy 。
# 7、点击 gateway-proxy 项目的【Settings】->【Secrets and variables】->【Actions】菜单,链接: https://github.com/phpdragon/gateway-proxy/settings/secrets/actions。
# 添加 GITEE_PRIVATE_SSH_KEY ,值为SSH私钥(~/.ssh/id_rsa文件内容);
# 添加 GITEE_PRIVATE_TOKEN ,值为Gitee私人令牌。
# 8、在Gitee中导入Github的项目 gateway-proxy, 这样可以使用Gitee提供的Github代码同步功能(同步功能自动创建的项目没有该功能)。
# 9、添加当前工作流配置文件,提交代码,便可通过push动作实现代码实时同步。
#
# 使用参考:
# https://zhuanlan.zhihu.com/p/102977226
# http://yikun.github.io/2020/01/17/%E5%B7%A7%E7%94%A8Github-Action%E5%90%8C%E6%AD%A5%E4%BB%A3%E7%A0%81%E5%88%B0Gitee/
# https://github.com/Yikun/hub-mirror-action/blob/master/README_CN.md
# https://help.github.com/cn/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets
########################################
name: Gitee repos mirror periodic sync job
on:
# push推送时触发
push:
# 定时任务触发
schedule:
# 每天北京时间9点跑
# Runs at 01:00 UTC (9:00 AM Beijing) every day
- cron: '0 1 * * *'
jobs:
run:
name: Sync GitHub to Gitee
runs-on: ubuntu-latest
steps:
- name: Mirror the Github repos to Gitee.
# 引用master分支的脚本支持
uses: phpdragon/hub-mirror-action@master
with:
# 需要被同步的源端账户名,如github/phpdragon,表示Github的账户: phpdragon。
src: github/phpdragon
# 需要同步到的目的端账户名,如gitee/phpdragon,表示Gitee的账户: phpdragon。
dst: gitee/phpdragon
# 用于目的端上传代码的SSH私钥,用于上传代码
dst_key: ${{ secrets.GITEE_PRIVATE_SSH_KEY }}
# 创建仓库的API tokens, 用于自动创建不存在的仓库
dst_token: ${{ secrets.GITEE_PRIVATE_TOKEN }}
# 仅同步静态列表,不会再动态获取需同步列表(黑白名单机制依旧生效),如“repo1,repo2,repo3”,当前的项目名称
static_list: "gateway-proxy"
# 强制更新
force_update: true
account_type: user
# clone方式,使用https、ssh方式进行clone
clone_style: ssh
#设置命令行超时时间为1小时
timeout: 1h
#开启Debug
debug: false