md/.github/workflows/build.yml

57 lines
1.3 KiB
YAML
Raw Normal View History

2020-05-02 20:31:24 +08:00
name: Build and Deploy
2020-12-02 14:37:05 +08:00
2020-05-02 19:45:26 +08:00
on:
push:
2021-02-26 10:47:40 +08:00
branches: [main]
2021-11-23 14:22:01 +08:00
workflow_dispatch:
2020-12-02 14:37:05 +08:00
2020-05-02 19:45:26 +08:00
jobs:
2020-05-02 20:31:24 +08:00
build-and-deploy:
2020-05-02 19:45:26 +08:00
runs-on: ubuntu-latest
steps:
2020-05-02 20:31:24 +08:00
- name: Checkout
2021-08-22 11:55:00 +08:00
uses: actions/checkout@v2.3.1
2020-05-02 20:31:24 +08:00
with:
persist-credentials: false
2021-02-26 10:47:40 +08:00
2020-11-25 09:47:08 +08:00
- name: Set up node
2021-01-30 11:39:13 +08:00
uses: actions/setup-node@v2
2020-11-25 09:47:08 +08:00
with:
2021-02-26 10:47:40 +08:00
node-version: "12"
2020-11-25 09:47:08 +08:00
check-latest: true
2021-02-26 10:47:40 +08:00
2020-11-25 09:47:08 +08:00
- name: Cache node modules
uses: actions/cache@v2
id: cache
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
2021-02-26 10:47:40 +08:00
2020-11-25 09:47:08 +08:00
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm install
2020-05-02 20:31:24 +08:00
2020-11-25 09:47:08 +08:00
- name: Build
2021-02-26 10:47:40 +08:00
run: npm run build
2020-05-02 20:31:24 +08:00
- name: Deploy
2021-11-09 09:36:59 +08:00
uses: JamesIves/github-pages-deploy-action@4.1.5
2020-05-02 20:31:24 +08:00
with:
2021-08-22 11:55:00 +08:00
branch: gh-pages
folder: dist
2021-04-25 11:05:56 +08:00
2021-11-09 09:36:59 +08:00
sync-to-gitee:
runs-on: ubuntu-latest
if: github.repository == 'doocs/md'
needs: build-and-deploy
steps:
2021-04-25 11:05:56 +08:00
- name: Sync to Gitee
2021-11-09 09:36:59 +08:00
uses: wearerequired/git-mirror-action@v1
2021-04-25 11:05:56 +08:00
env:
SSH_PRIVATE_KEY: ${{ secrets.GITEE_RSA_PRIVATE_KEY }}
with:
source-repo: git@github.com:doocs/md.git
destination-repo: git@gitee.com:Doocs/md.git