使用 Github Action 将 github 仓库同步到 gitee

背景

最近将 CI/CD 流程改造了一波,使用 ArgoCD 做 gitops,这样所有的集群 Yaml 文件就都存放在了 github 上的一次仓库里。
但是小服务器放在家里,从 github 上拉代码时总是时不时有网络问题,导致集群资源无法及时更新。

Gitee 提供了一个仓库镜像的功能,所以我目前采用的方式就是:

CI 构建镜像 -> 推送最新配置代码到 Github 仓库 -> Gitee 仓库同步 Github 仓库 -> 集群 ArgoCD 拉取 Gitee 仓库配置。

但是到 3 月底这个功能就要关闭了,得寻找个替代方案了。

要么就是在 CI 过程中,既推送到 Github 仓库,又推送到 Gitee 仓库,但是这样感觉好麻烦,在搜索的过程中,看到了一个 Github Action:sync-gitee-mirror,专门用来将 Github 的仓库,推送到 Gitee 中。

这样就可以在 Github 的配置仓库中,增加一个 workflow,每当配置文件更新时,就触发此 action,主动将代码同步到 Gitee 仓库中。

使用

以我的集群配置仓库 gitops-configs 为例,在此仓库根目录下新建文件 .github/workflows/micrror-to-gitee.yaml,并填入如下内容:

name: 镜像仓库到 Gitee
on:
  push:
    branches:
      - main
env:
  # 仓库名称
  REPO_NAME: ${{ github.event.repository.name }}

jobs:
  mirror-to-gitee:
    name: 同步到 Gitee
    runs-on: ubuntu-latest

    steps:
      - name: Mirror repo to Gitee.
        uses: abersheeran/sync-gitee-mirror@v1-beta
        with:
          repository: xuxusheng/${{ env.REPO_NAME }}
          username: xuxusheng
          password: ${{ secrets.GITEE_PASSWORD }}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值