Pages CI #649
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: Pages CI | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
workflow_dispatch: | |
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
# Allow one concurrent deployment | |
concurrency: | |
group: "pages" | |
cancel-in-progress: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
if: "!(github.event_name == 'push' && contains(github.event.head_commit.message, '[skip ci]'))" | |
steps: | |
- name: Check out project | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "::set-output name=dir::$(yarn cache dir)" | |
- uses: actions/cache@v2 | |
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
- name: Install dependencies | |
run: yarn | |
- name: Run code quality tools | |
run: yarn lint | |
- name: Build development website | |
if: ${{ github.event_name == 'pull_request' }} | |
run: yarn build --environment development | |
- name: Build production website | |
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }} | |
run: yarn build | |
- name: Setup Pages | |
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }} | |
id: pages | |
uses: actions/configure-pages@v2 | |
- name: Upload artifact | |
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }} | |
uses: actions/upload-pages-artifact@v1 | |
with: | |
path: ./public | |
# Deployment job | |
deploy: | |
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }} | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v1 |