跳至主要內容

github代码备份到gitee仓库-工作流

Mr.nxg2023年4月4日运维gitgithub工作流大约 1 分钟

大概思路

从本地(windows)使用git将代码提交到GitHub某仓库,然后触发某仓库GitHub工作流,使其将代码推送到gitee仓库。

前置知识

大致步骤

关于GitHub工作流与密钥配置对应图:

image-20230404224357484
image-20230404224357484

1.配置本地密钥到gitee,至于怎么配置可以参考git多账号配置

2.配置GitHub公钥

该公钥要与gitee配置公钥对应上

本地密钥id_rsa_gitee.pub内容复制到GitHub中

image-20230404221056949
image-20230404221056949

粘贴到如下图:

image-20230404221134689
image-20230404221134689

同理将上的公钥复制粘贴到gitee上

配置示例如下:

image-20230404222501712
image-20230404222501712

3.配置GitHub仓库密钥

需要在GitHub仓库添加对应secrets

如下图:

image-20230404225010003
image-20230404225010003

注意:此处的私钥要与gitee配置的公钥成对存在

如下图:

image-20230404225213255
image-20230404225213255

附件

参考:yanglbme/gitee-pages-action

gitee-pages-action

报错

WARNING: StrictHostKeyChecking disabled
Cloning into bare repository 'hexo-theme-gitee-blog.git'...
SOURCE=git@github.com:hisnxg/hexo-theme-gitee-blog.git
DESTINATION=git@gitee.com:hisnxg/hisnxg.git
DRY RUN=false
Warning: Permanently added 'github.com' (ED25519) to the list of known hosts.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
fatal: not a git repository (or any parent up to mount point /github)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

原因:gitee配置的此公钥要与GitHub公钥成对存在。

添加即可解决

image-20230404223214170
image-20230404223214170

如未解决可参考:https://github.com/yanglbme/gitee-pages-action/issues/29