1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-04-27 05:58:26 -04:00

106 lines
3.4 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: "!contains(github.event.head_commit.message, '[skip ci]')"
timeout-minutes: 10
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
steps:
- name: Wait for Netlify
# installing via `npx` each run takes a long time, but deploys always take longer
run: npx netlify-cli watch
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@v1
with:
node-version: 12.x
- name: Install Lighthouse CI
run: |
npm install -g @lhci/cli
lhci --version
- 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/netlify-analytics-review/ \
--collect.url=https://deploy-preview-${{ github.event.number }}--jakejarvis.netlify.app/notes/how-to-pull-request-fork-github/amp.html
- name: Audit jarv.is
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/netlify-analytics-review/ \
--collect.url=https://jarv.is/notes/how-to-pull-request-fork-github/amp.html
- name: Upload results as artifact
uses: actions/upload-artifact@v1
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@v1
with:
node-version: 12.x
- uses: actions/setup-go@v2
with:
go-version: 1.14.x
- name: Get Yarn cache location
# 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@v1
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: Lint
run: yarn lint
continue-on-error: true
- name: Build
run: yarn build:preview
- name: Percy snapshots
# don't run for all of dependabot's PRs -- I'm using the free plan...
if: "!contains(github.actor, '[bot]')"
uses: percy/snapshot-action@v0.1.0
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}