2021-02-10 11:35:54 +08:00
|
|
|
name: Build Upload Site
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches: [master, dev]
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
publish:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Get yarn cache directory path
|
|
|
|
id: yarn-cache-dir-path
|
|
|
|
run: echo "::set-output name=dir::$(yarn cache dir)"
|
|
|
|
|
|
|
|
- name: Cache Packages
|
|
|
|
id: yarn-cache
|
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
|
|
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/package-lock.json') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-yarn-
|
|
|
|
|
|
|
|
- name: Install and build
|
|
|
|
run: |
|
|
|
|
yarn install
|
|
|
|
yarn build
|
|
|
|
|
2021-02-10 11:38:56 +08:00
|
|
|
- name: Get Branch Name
|
2021-02-10 11:52:34 +08:00
|
|
|
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
|
2021-02-10 11:38:56 +08:00
|
|
|
|
2021-02-10 11:35:54 +08:00
|
|
|
- name: Get Site ID
|
2021-02-10 11:46:00 +08:00
|
|
|
if: env.BRANCH_NAME == 'master'
|
2021-02-10 11:35:54 +08:00
|
|
|
run: |
|
2021-02-10 11:52:34 +08:00
|
|
|
echo "SITE_ID=${{ secrets.PROD_SITE_ID }}" >> $GITHUB_ENV
|
2021-02-10 11:35:54 +08:00
|
|
|
|
|
|
|
- name: Get Site ID
|
2021-02-10 11:46:00 +08:00
|
|
|
if: env.BRANCH_NAME == 'dev'
|
2021-02-10 11:35:54 +08:00
|
|
|
run: |
|
2021-02-10 11:52:34 +08:00
|
|
|
echo "SITE_ID=${{ secrets.DEV_SITE_ID }}" >> $GITHUB_ENV
|
2021-02-10 11:35:54 +08:00
|
|
|
|
|
|
|
- name: Publish
|
|
|
|
uses: netlify/actions/cli@master
|
|
|
|
with:
|
2021-02-10 12:09:37 +08:00
|
|
|
args: deploy --dir=docs/.vuepress/dist --prod --message "Production ${{ github.sha }}"
|
2021-02-10 11:35:54 +08:00
|
|
|
env:
|
2021-02-10 11:52:34 +08:00
|
|
|
NETLIFY_SITE_ID: ${{ env.SITE_ID }}
|
2021-02-10 11:35:54 +08:00
|
|
|
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
|