使用Github Actions自动同步到Gitee仓库

Github Actions是Github推出的自动化CI/CD的功能,我们将使用Github Actions让Github仓库同步到Gitee。

1、生成SSH公钥

执行命令:ssh-keygen -t rsa -C "youremail@example.com",连续三次回车,id_rsa 为私钥,id_rsa.pub为公钥
如果提示:already exists(已经存在),则可以到电脑位置:C:\Users\电脑账号名\ .ssh 直接使用
不使用默认SSH参考:生成/添加SSH公钥

2、GitHub项目配置SSH密钥

在Github项目
Settings->Secrets->Actions,名称为:GITEE_RSA_PRIVATE_KEY,值为:上面生成SSH的私钥在这里插入图片描述在这里插入图片描述

3、GitHub配置SSH公钥

在Github
Settings->SSH and GPG keys->New SSH key,名称为:GITEE_RSA_PUBLIC_KEY,值为:上面生成SSH的公钥
在这里插入图片描述

4、Gitee配置SSH公钥

在Gitee
设置->安全设置->SSH公钥,标题为:GITEE_RSA_PUBLIC_KEY,值为:上面生成SSH的公钥
在这里插入图片描述

5、GitHub创建Github workflow

在Github项目
Actions创建一个新的workflow
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

name: Sync To Gitee

on: [ push, delete, create ]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Sync to Gitee
        uses: wearerequired/git-mirror-action@master
        env:
          # 注意在 Settings->Secrets 配置 GITEE_RSA_PRIVATE_KEY
          SSH_PRIVATE_KEY: ${{ secrets.GITEE_RSA_PRIVATE_KEY }}
        with:
          # 注意替换为你的 GitHub 源仓库地址
          source-repo: git@github.com:github-username/github-repositoryname.git
          # 注意替换为你的 Gitee 目标仓库地址
          destination-repo: git@gitee.com:gitee-username/gitee-repositoryname.git
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值