wongjiahau/ttap-web

View on GitHub
.github/workflows/action.yml

Summary

Maintainability
Test Coverage
name: BuildAndDeploy

on:
  push:
    branches: ["master"]
  pull_request:
    branches: ["master"]

jobs:
  build:
    runs-on: macos-latest
    strategy:
      matrix:
        node-version: [14.x]
    env:
      CI: false
    steps:
      - uses: actions/checkout@v2
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node-version }}
      - run: npm install

      # Check format
      - run: npm run format:check

      # Build
      - run: ./scripts/build

      # Test
      - run: npm run test

      # Upload artifacts for deploy job
      - uses: actions/upload-artifact@master
        with:
          name: build
          path: ./build

  deploy:
    runs-on: macos-latest
    strategy:
      matrix:
        node-version: [14.x]
    needs: build
    # Only allow deployment on master branch
    # Refer https://stackoverflow.com/a/58142412/6587634
    if: github.ref == 'refs/heads/master'
    steps:
      - uses: actions/checkout@v2
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node-version }}
      - uses: actions/download-artifact@master
        with:
          name: build
          path: ./build
      - run: npm install --global surge
      - run: surge --domain https://ttap.surge.sh --project ./build --token ${{ secrets.SURGE_TOKEN }}