GitHub Actions
Gitee與GitHub自動同步
當(dāng)github上的項目代碼master分支提交后民镜,gitee自動同步捕捂。如何實現(xiàn)呢。主要通過github action實現(xiàn)
我們想將luoyunchong/lin-cms-dotnetcore同步到igeekfan/lin-cms-dotnetcore上面,需要做的非常簡單嘁字,只需要2步:
1.將Gitee的私鑰夫椭,上傳到項目的setting的Secrets中掸掸。
[圖片上傳失敗...(image-3b3f6-1589169526728)]
前提,該私鑰對應(yīng)的公鑰在gitee上蹭秋,windows(C:\Users\Computer.ssh)扰付,其中id_rsa是私鑰,id_rsa.pub內(nèi)容是公鑰仁讨,具體在gitee上增加ssh公鑰的過程羽莺,請參考SSH 公鑰設(shè)置
- 改source-repo、destination-repo的值
lin-cms-dotnetcore gitee同步腳本
name: Publish
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Sync to Gitee ??
uses: wearerequired/git-mirror-action@master
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
with:
source-repo: "git@github.com:luoyunchong/lin-cms-dotnetcore.git"
destination-repo: "git@gitee.com:igeekfan/lin-cms-dotnetcore.git"
每一個steps就是在jobs里執(zhí)行命令洞豁,一個jobs可以有多個steps,
steps字段指定每個 Job 的運行步驟的介紹
jobs.<job_id>.steps.name 步驟名稱
jobs.<job_id>.steps.env 該步驟所需的環(huán)境變量盐固。
jobs.<job_id>.steps.uses 使用的組件
jobs.<job_id>.steps.with 多個值(這個參數(shù)其實是提交給容器的CMD)