Skip to main content

demo2.yml 解释

1、运行 在 mater 分支上运行 yarnyarn build

2、将 build 文件夹的内容推送到另一仓库的 master 分支

使用示例

使用 Github Actions 将 repoA 构建之后的内容推送至 repoB

repoA 私有;repoB公有

1、创建 repoA repoB 仓库

2、创建 SSH keys

$ ssh-keygen -t ed25519 -C "your_email@example.com"

生成之后注意记录下 公钥、私钥 的位置

将 公钥、私钥 保存下来

3、repoA 添加私钥

repoA -> setting -> Secrets -> New repository secret

  • Name: DEPLOY_PRIVATE_KEY
  • Value: 私钥值

4、repoB 添加公钥

repoB -> setting -> Deploy keys -> Add deploy key

  • Title: DEPLOY_PUBLIC_KEY
  • Key: 公钥值
  • Allow write access: YES

5、.github/workflows/autoBuildDeploy.yml DEMO

name: Build and Deploy
on:
push:
branches:
- master
jobs:
build-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2.3.1

- name: Install and Build
run: |
yarn
yarn build

- name: Deploy
uses: s0/git-publish-subdir-action@develop
env:
REPO: git@github.com:ovim/ovim.github.io.git
BRANCH: master
FOLDER: build
SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_PRIVATE_KEY }}

6、推送测试