💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
## 一、概述 利用GitHub Actions,将GitHub仓库自动备份到 Gitee; ## 二、GitHub账户级操作 ### **生成ssh** git bash 中敲入命令(密码可全部输空),会在`~/.ssh`文件夹下生成`id_rsa.pub`文件和`id_rsa`文件,分别存放公钥和私钥; ``` ssh-keygen -t rsa -C "4170804@qq.com" ``` ![](https://img.kancloud.cn/30/b0/30b0b130893da189e3b95d92db844de2_1239x647.png) ![](images/screenshot_1635311727760.png) ### **将公钥添加到Gitee** Gitee: 「设置」–>「安全设置」–>「SSH公钥」; ![](https://img.kancloud.cn/5c/f3/5cf3d760523900ddd5cd15db580c1aec_1920x942.png) 将id_rsa.pub文件中的内容,完整的拷贝过来; ![](https://img.kancloud.cn/55/3f/553f46bd31a128e430503b79dfbfebf3_1920x942.png) ![](https://img.kancloud.cn/46/a7/46a720224b513bc4abf825bf639d57cf_1920x942.png) ### **将公钥添加到GitHub** 「Settings」–>「SSH And GPG keys]; ![](https://img.kancloud.cn/3d/1f/3d1f3774a353a8f9d05deb1fefd4c947_1920x942.png) 将id_rsa.pub文件中的内容,完整的拷贝过来; ![](https://img.kancloud.cn/08/23/082301c75b960b3266ad7de0a70897e0_1920x942.png) **截止到这里,都是整个github级别的操作,接下来,就是指定仓库级的操作了;** ## 三、GitHub仓库级操作 ### **将私钥添加到待同步GitHub 仓库** 进入需要同步的仓库GitHub Repository: 「Settings」–>「Secrets」; ![](https://img.kancloud.cn/53/5a/535a19f9adb3298d5f31a90aa1ecf9e8_1920x942.png) ![](https://img.kancloud.cn/57/b2/57b2bacb57e6663fea5956a79671677f_1920x942.png) 注意,这里定义的私钥名称,需要记住,后面作为变量名,要提供给GitHub Action的脚步使用,比如这里命名为GITEEPRIVATE; ### **待同步仓库配置GitHub Actions** 进入需要同步的仓库GitHub Repository: ![](https://img.kancloud.cn/14/d4/14d44432ffb215072bad3ddb2bce523a_1920x942.png) ![](https://img.kancloud.cn/2d/ab/2dab849132ca2df2d01e19d3c7689b93_1920x942.png) 编辑该位置文件,内容调整为: ``` name: Mirror to Gitee Repo on: [ push, delete, create ] concurrency: group: git-mirror jobs: git-mirror: runs-on: ubuntu-latest steps: - uses: wearerequired/git-mirror-action@v1.1.0 env: SSH_PRIVATE_KEY: ${{ secrets.GITEEPRIVATE }} with: source-repo: "git@github.com:4170804/rayplatform.git" destination-repo: "git@gitee.com:4170804/rayplatform.git" ``` ![](../images/screenshot_1635313966328.png) ### **执行结果** 设置完毕后,Github Action将会把提交自动同步到gitee; ![](https://img.kancloud.cn/ff/69/ff6936a1f0e6065ae4d2ed6d0ce09983_1920x942.png) 比如: 更改了github工程中的文本: ![](https://img.kancloud.cn/c3/b4/c3b4f5784c7bf2ebf174022ba9052c3f_1920x942.png) 自动同步后; ![](https://img.kancloud.cn/4f/c8/4fc86556d7fe74502bd58b127827cc25_1920x942.png)