Skip to content

Commit c8309be

Browse files
author
Roberto Santalla
authored
ci/staging: leverage node_modules and gatsby output on staging as well (#1188)
1 parent 61a7cb6 commit c8309be

File tree

1 file changed

+32
-24
lines changed

1 file changed

+32
-24
lines changed

.github/workflows/staging.yml

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,9 @@ env:
2626
GATSBY_NEWSLETTER_FORM_ID: 1420
2727

2828
jobs:
29-
update-dependencies:
30-
name: Update node module dependencies
31-
runs-on: ubuntu-latest
32-
steps:
33-
- name: Checkout project
34-
uses: actions/checkout@v2
35-
- name: Use Node.js 16.xs
36-
uses: actions/setup-node@v2
37-
with:
38-
node-version: '16.x'
39-
registry-url: 'https://registry.npmjs.org'
40-
- name: Restore cache
41-
uses: actions/cache@v2
42-
with:
43-
path: '**/node_modules'
44-
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}
45-
- name: Install dependencies
46-
run: npm install
4729
lint:
4830
name: Lint code
4931
runs-on: ubuntu-latest
50-
needs:
51-
- update-dependencies
5232
steps:
5333
- name: Checkout project
5434
uses: actions/checkout@v2
@@ -57,13 +37,28 @@ jobs:
5737
with:
5838
node-version: '16.x'
5939
registry-url: 'https://registry.npmjs.org'
60-
- name: Restore cache
40+
cache: 'npm'
41+
- name: Restore node_modules cache
6142
uses: actions/cache@v2
6243
with:
6344
path: '**/node_modules'
6445
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}
65-
- name: Install dependencies
46+
- name: Install
6647
run: npm install
48+
- name: Restore Gatsby cache
49+
uses: actions/cache@v3
50+
with:
51+
# Gatsby requires both .cache and public. It will refuse to use .cache/ if public/ is not present.
52+
path: |
53+
.cache
54+
public
55+
# Cache will not be used by Gatsby if the following files change:
56+
# https://www.gatsbyjs.com/docs/build-caching/
57+
# We use the commit SHA on the key to prevent an ever-living cache entry keyed as "main".
58+
key: pr-gatsby-${{ hashFiles('package.json', 'gatsby-config.js', 'gatsby-node.js') }}-${{ github.ref }}-${{ github.sha }}
59+
restore-keys: |
60+
pr-gatsby-${{ hashFiles('package.json', 'gatsby-config.js', 'gatsby-node.js') }}-${{ github.ref }}-
61+
pr-gatsby-${{ hashFiles('package.json', 'gatsby-config.js', 'gatsby-node.js') }}-
6762
- name: Check formatting
6863
run: |
6964
npm run format
@@ -99,13 +94,26 @@ jobs:
9994
with:
10095
node-version: '16.x'
10196
registry-url: 'https://registry.npmjs.org'
102-
- name: Restore cache
97+
cache: 'npm'
98+
- name: Restore node_modules cache
10399
uses: actions/cache@v2
104100
with:
105101
path: '**/node_modules'
106102
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}
107-
- name: Install dependencies
103+
- name: Install
108104
run: npm install
105+
- name: Restore Gatsby cache
106+
uses: actions/cache@v3
107+
with:
108+
# Gatsby requires both .cache and public. It will refuse to use .cache/ if public/ is not present.
109+
path: |
110+
.cache
111+
public
112+
# Cache will not be used by Gatsby if the following files change:
113+
# https://www.gatsbyjs.com/docs/build-caching/
114+
key: pr-gatsby-${{ hashFiles('package.json', 'gatsby-config.js', 'gatsby-node.js') }}-${{ github.ref }}
115+
restore-keys: |
116+
pr-gatsby-${{ hashFiles('package.json', 'gatsby-config.js', 'gatsby-node.js') }}-
109117
- name: Build project
110118
run: npm run build:gatsby
111119
- name: Checks if AWS CLI already installed

0 commit comments

Comments
 (0)