1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-04-26 14:38:30 -04:00

101 lines
3.2 KiB
YAML

name: CI
on:
push:
branches:
- main
pull_request:
jobs:
deploy:
runs-on: ubuntu-latest
# "[skip ci]" also causes Netlify to skip, so these are automatically in harmony
# https://docs.netlify.com/site-deploys/manage-deploys/#skip-a-deploy
if: "github.actor == 'jakejarvis' && !contains(github.event.head_commit.message, '[skip ci]')"
timeout-minutes: 20
steps:
- name: Wait for Netlify
# installing via `npx` each run takes a long time, but deploys always take longer
run: npx netlify-cli watch
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
audit:
runs-on: ubuntu-latest
needs: deploy
env:
LHCI_TOKEN: ${{ secrets.LHCI_TOKEN }}
LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 2
lfs: false
- uses: actions/setup-node@v2
with:
node-version: 16.x
- name: Install LHCI
run: npm install -g @lhci/cli
- name: Check LHCI
run: |
lhci --version
lhci healthcheck
- name: Audit deploy preview
if: "github.event_name == 'pull_request'"
continue-on-error: true
run: |
lhci autorun \
--collect.url=https://deploy-preview-${{ github.event.number }}--jakejarvis.netlify.app/ \
--collect.url=https://deploy-preview-${{ github.event.number }}--jakejarvis.netlify.app/notes/how-to-pull-request-fork-github/
- name: Audit production site
if: "github.event_name == 'push' && github.ref == 'refs/heads/main'"
continue-on-error: true
run: |
lhci autorun \
--collect.url=https://jarv.is/ \
--collect.url=https://jarv.is/notes/how-to-pull-request-fork-github/
- name: Upload results as artifact
uses: actions/upload-artifact@v2
if: success()
with:
name: lhci-results
path: ./.lighthouseci
lint:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip ci]')"
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
lfs: false
- uses: actions/setup-node@v2
with:
node-version: 16.x
- name: Get Yarn cache path
# https://github.com/actions/cache/blob/master/examples.md#node---yarn
# https://github.com/actions/cache/issues/60
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install --no-ignore-optional --frozen-lockfile
- name: Audit dependencies
run: yarn audit || true
continue-on-error: true
- name: Build preview
run: yarn build:hugo --environment development --baseURL / --buildDrafts --buildFuture
- name: Lint
run: yarn lint
- name: Percy snapshots
uses: percy/snapshot-action@v0.1.2
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}