Skip to content

Commit abba2a8

Browse files
Split CI checks from Netlify previews (#97)
* Run tests and visual regression in GitHub Actions * Leave Netlify deploy previews build-only * For production, _publish_ in Netlify _after_ GitHub Actions pass
1 parent 3bad20c commit abba2a8

3 files changed

Lines changed: 64 additions & 9 deletions

File tree

.github/workflows/vrt.yml

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,33 @@
1-
on: [push]
1+
name: CI
2+
3+
on: [push, pull_request]
4+
5+
permissions:
6+
contents: read
7+
statuses: write
28

39
jobs:
4-
build:
10+
test:
11+
runs-on: ubuntu-latest
12+
name: Test
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v6
17+
18+
- name: Setup Node
19+
uses: actions/setup-node@v6
20+
with:
21+
node-version-file: '.nvmrc'
22+
23+
- name: Install dependencies
24+
run: npm install
25+
26+
- name: Test
27+
run: npm test
28+
29+
visual-regression:
30+
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/master'
531
runs-on: ubuntu-latest
632
name: Lost Pixel
733

@@ -27,3 +53,32 @@ jobs:
2753
uses: lost-pixel/lost-pixel@v3.22.0
2854
env:
2955
LOST_PIXEL_API_KEY: ${{ secrets.LOST_PIXEL_API_KEY }}
56+
57+
deploy-production:
58+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
59+
runs-on: ubuntu-latest
60+
name: Deploy production
61+
needs: [test, visual-regression]
62+
63+
steps:
64+
- name: Checkout
65+
uses: actions/checkout@v6
66+
67+
- name: Setup Node
68+
uses: actions/setup-node@v6
69+
with:
70+
node-version-file: '.nvmrc'
71+
72+
- name: Install dependencies
73+
run: npm install
74+
75+
- name: Build app
76+
run: npm run build
77+
78+
- name: Deploy to Netlify
79+
run: >
80+
npx --yes netlify-cli deploy --prod --dir=dist --site
81+
"$NETLIFY_SITE_ID" --auth "$NETLIFY_AUTH_TOKEN"
82+
env:
83+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
84+
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@ Source for [johnkurkowski.com](https://johnkurkowski.com).
1616

1717
npm test
1818

19-
Tests are run in CI and must pass prior to deployment.
19+
Tests are run in CI and must pass before production deploy, i.e. pushes to
20+
trunk. Branches deploy regardless of CI passing.
2021

21-
[Lost Pixel](https://app.lost-pixel.com/) visual regression review is run during
22-
CI, but does not block deployment. If there are visual differences in your
23-
build, they require manual, asynchronous review. Before push, you can preview
24-
Lost Pixel's snapshots against your running local server in production mode.
22+
Before push, you can preview [Lost Pixel](https://app.lost-pixel.com/) VRT's
23+
snapshots against your running local server in production mode.
2524

2625
npm run build
27-
npm run serve &
26+
npm run preview &
2827
npx lost-pixel local

netlify.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[build]
2-
command = "npm test && npm run build"
2+
command = "npm run build"
3+
ignore = "[ \"$CONTEXT\" = \"production\" ]"
34
publish = "dist/"

0 commit comments

Comments
 (0)