Skip to content

Commit

Permalink
Skip build when cached against commit SHA
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrotherham committed Feb 28, 2023
1 parent 4f4d8fc commit 4073f53
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,30 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3

- name: Restore build
uses: actions/cache@v3
id: build-cache

with:
key: build-cache-${{ runner.os }}-${{ github.sha }}
path: deploy/public

- name: Setup Node.js
uses: actions/setup-node@v3
if: steps.build-cache.outputs.cache-hit != 'true'

with:
cache: npm
node-version-file: .nvmrc

- name: Install dependencies
if: steps.build-cache.outputs.cache-hit != 'true'
run: npm ci

- name: Build
if: steps.build-cache.outputs.cache-hit != 'true'
run: npm run build

- name: Cache build
uses: actions/cache/save@v3
with:
key: build-cache-${{ runner.os }}-${{ github.sha }}
path: deploy/public

# Share data between the build and deploy jobs so we don't need to run `npm run build` again on deploy
# Upload the deploy folder as an artifact so it can be downloaded and used in the deploy job
- name: Upload artifact
Expand Down

0 comments on commit 4073f53

Please sign in to comment.