heti/.github/workflows/deploy.yml

54 lines
1.8 KiB
YAML
Raw Normal View History

2020-02-21 01:18:31 +08:00
name: deploy
on:
push:
branches:
- master
jobs:
build-and-deploy:
runs-on: ubuntu-latest
2022-03-25 06:53:22 +08:00
needs: check-env
2020-02-21 01:18:31 +08:00
steps:
2020-02-21 01:49:22 +08:00
- name: Checkout
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v1
with:
2022-12-19 22:17:58 +08:00
node-version: 18
2020-02-21 01:49:22 +08:00
- name: NPM Install and Test
run: |
npm install
npm run test
npm run build
- name: Publish
2022-03-03 06:39:55 +08:00
if: needs.check-env.outputs.check-npm == 'true'
2020-02-21 01:49:22 +08:00
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
- name: Deploy to gh-pages
2022-03-03 06:39:55 +08:00
if: needs.check-env.outputs.check-access == 'true'
2020-02-21 01:49:22 +08:00
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
BRANCH: gh-pages
FOLDER: _site
2022-03-03 06:39:55 +08:00
check-env:
runs-on: ubuntu-latest
outputs:
check-npm: ${{ steps.check-npm.outputs.defined }}
check-access: ${{ steps.check-access.outputs.defined }}
2022-03-23 07:31:54 +08:00
steps:
2022-03-03 06:39:55 +08:00
- id: check-npm
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
if: ${{ env.NPM_TOKEN != '' }}
run: echo "::set-output name=defined::true"
- id: check-access
env:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
if: ${{ env.ACCESS_TOKEN != '' }}
run: echo "::set-output name=defined::true"