binhonglee/GlobeTrotte

View on GitHub
.github/workflows/deploy.yml

Summary

Maintainability
Test Coverage
name: Deploy prod
on:
  push:
    branches:
    - main

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2

    - name: Cache please
      id: cache-please
      uses: actions/cache@v1
      with:
        path: ~/.please
        key: ${{ hashfiles('**/.plzconfig') }}-please
    - name: Cache pnpm-store
      id: cache-pnpm-store
      uses: actions/cache@v1
      with:
        path: ~/.local/share/pnpm/store/v3
        key: ${{ hashfiles('**/package.json') }}-pnpm-store
    - name: Cache node_modules
      id: cache-node-modules
      uses: actions/cache@v1
      with:
        path: node_modules
        key: ${{ hashFiles('**/package.json') }}-pnpm

    - name: Use Node.js
      uses: actions/setup-node@v1
      with:
        node-version: '16.13.1'
    - name: Use Go
      uses: actions/setup-go@v2
      with:
        go-version: 1.15.x

    - name: Install PNPM
      run: sudo npm i -g pnpm@7.1.0

    - name: Run go_mod
      run: ./pleasew go_mod

    - name: Build
      run: ./pleasew build --show_all_output //deploy

    - name: Push commit
      uses: EndBug/add-and-commit@v9
      with:
        message: 'Push go.mod changes to BUILD file'

    - name: Remove BUILD file in deploy dir
      run: rm deploy/BUILD

    - name: Deploy
      uses: peaceiris/actions-gh-pages@v3
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
        publish_dir: ./deploy
        publish_branch: deploy
        commit_message: ${{ github.event.head_commit.message }}
        user_name: 'github-actions[bot]'
        user_email: 'github-actions[bot]@users.noreply.github.com'
        # Not that this is jekyll but to prevent having the weird '.nojekyll' file
        enable_jekyll: true