Github pages 同步到Gitee pages 并自動(dòng)更新Gitee pages | 您所在的位置:網(wǎng)站首頁(yè) › 屬鼠住什么方位房間 › Github pages 同步到Gitee pages 并自動(dòng)更新Gitee pages |
由于 Gitee Pages 的訪問(wèn)速度很快,很多朋友會(huì)選擇 Gitee Pages 部署項(xiàng)目(如:個(gè)人博客、開(kāi)源項(xiàng)目國(guó)內(nèi)鏡像站點(diǎn))。但是它不像 GitHub Pages 那樣,一提交代碼就能自動(dòng)更新 Pages,因?yàn)?Gitee 的自動(dòng)部署屬于 Gitee Pages Pro 的服務(wù)。 有大佬開(kāi)發(fā)了自動(dòng)更新Gitee pages的action,其中也包含了github 同步到gitee 的代碼,詳見(jiàn):https://github.com/yanglbme/gitee-pages-action 但有時(shí)候我想在同步之前對(duì)代碼做些處理,比如替換github.io的鏈接,但是保持此github倉(cāng)庫(kù)不變,就需要自己寫(xiě)同步代碼了,我寫(xiě)好的代碼如下: 注意:需要在倉(cāng)庫(kù)的settings(不是賬號(hào)的settings) => secrets/action ,添加New repository secret ,名字是GITEE_TOKEN, 值就是gitee token name: Github 同步到 Gitee # Controls when the action will run. on: # Triggers the workflow on push or pull request events but only for the main branch push: branches: [ master ] #pull_request: # branches: [ main ] #schedule: #- cron: '30 0/3 * * *' # Allows you to run this workflow manually from the Actions tab workflow_dispatch: jobs: run: name: 把該倉(cāng)庫(kù)同步到 Gitee(使用白名單只同步這個(gè)倉(cāng)庫(kù)) runs-on: ubuntu-latest steps: # - name: Mirror Github to Gitee with white list # uses: Yikun/hub-mirror-action@master # with: # src: github/nmy # dst: gitee/nmy # dst_key: ${{ secrets.GITEE_PRIVATE_KEY }} # dst_token: ${{ secrets.GITEE_TOKEN }} # mappings: "nmy.github.io=>nmy" # static_list: "nmy.github.io" # force_update: true # debug: true - name: Mirror Github to Gitee with white list env: GITEE_TOKEN: ${{ secrets.GITEE_TOKEN }} run: | git config --global user.email [email protected] git config --global user.name nmy git clone https://github.com/nmy/nmy.github.io.git ls -al mv nmy.github.io nmy && cd nmy pwd find . -type f | xargs sed -i "s/nmy.github.io/nmy.gitee.io/g" git add . git commit -m "update" -a git push --force --quiet https://nmy:"$GITEE_TOKEN"@gitee.com/nmy/nmy.git master:master |
CopyRight 2018-2019 實(shí)驗(yàn)室設(shè)備網(wǎng) 版權(quán)所有 |