Update README.md #85
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Test Workflow | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
types: [opened, synchronize] | |
workflow_dispatch: | |
inputs: | |
PERFORM_RELEASE: | |
description: '[Release] perform release' | |
required: false | |
default: 'false' | |
type: boolean | |
jobs: | |
check-permission: | |
runs-on: ubuntu-latest | |
steps: | |
# this action will fail the whole workflow if permission check fails | |
- name: check permission | |
uses: zowe-actions/shared-actions/permission-check@main | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
build-test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: '[Prep 1] Checkout' | |
uses: actions/checkout@v2 | |
- name: '[Prep 2] Cache node modules' | |
uses: actions/cache@v2 | |
with: | |
# npm cache files are stored in `~/.npm` on Linux/macOS | |
path: | | |
~/.npm | |
~/.nvm/.cache | |
~/.nvm/versions | |
key: ${{ runner.os }}-build-cache-node-modules-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-cache-node-modules- | |
- name: '[Prep 3] Setup Node' | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 8.11.4 | |
- name: '[Build] Nodejs project build' | |
run: npm --prefix src run build | |
- name: '[Test] Nodejs project unit test' | |
run: npm --prefix src run test | |
deploy: | |
runs-on: ubuntu-latest | |
needs: [check-permission, build-test] | |
if: ${{ success() && github.event_name == 'push' }} | |
steps: | |
- name: '[Deploy] Deploy to demo server' | |
uses: appleboy/ssh-action@master | |
if: ${{ success() && github.event_name == 'push' }} | |
with: | |
host: ${{ secrets.DEMO_SERVER_HOST }} | |
username: ${{ secrets.DEMO_SERVER_USERNAME }} | |
key: ${{ secrets.DEMO_SERVER_KEY }} | |
script: | | |
sudo apt -y install curl | |
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash | |
source ~/.profile | |
nvm install v8.11.4 | |
nvm use v8.11.4 | |
cd /root/zebra | |
git pull origin main | |
cd src | |
npm install | |
npm install -g forever@4.0.3 | |
forever stopall | |
forever start bin/www | |