Skip to content

Commit 103d2ca

Browse files
author
Peter Bengtsson
authored
experiment with npm install reusable workflow (#33480)
1 parent 9d41f5b commit 103d2ca

18 files changed

+46
-145
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Node set up composite
2+
3+
description: Will set up Node and install all packages by caching node_modules
4+
5+
runs:
6+
using: 'composite'
7+
steps:
8+
- name: Cache node_modules
9+
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7
10+
with:
11+
path: node_modules
12+
key: ${{ runner.os }}-node_modules-${{ hashFiles('package*.json') }}
13+
14+
- name: Setup node
15+
uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516
16+
with:
17+
node-version: '16.17.0'
18+
cache: npm
19+
20+
- name: Install dependencies
21+
shell: bash
22+
run: npm install --prefer-offline --no-audit --ignore-scripts

.github/workflows/check-broken-links-github-github.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,10 @@ jobs:
5252
path: docs-early-access
5353
ref: main
5454

55-
- name: Setup Node
56-
uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516
57-
with:
58-
node-version: '16.17.0'
59-
cache: npm
60-
6155
- name: Merge docs-early-access repo's folders
6256
run: .github/actions-scripts/merge-early-access.sh
6357

64-
- name: Install Node.js dependencies
65-
run: npm ci
58+
- uses: ./.github/actions/node-npm-setup
6659

6760
- name: Build server
6861
run: npm run build

.github/workflows/code-lint.yml

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,12 @@ concurrency:
3434
jobs:
3535
lint:
3636
if: github.repository == 'github/docs-internal' || github.repository == 'github/docs'
37-
runs-on: ubuntu-latest
37+
runs-on: ${{ fromJSON('["ubuntu-latest", "ubuntu-20.04-xl"]')[github.repository == 'github/docs-internal'] }}
3838
steps:
3939
- name: Check out repo
4040
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
4141

42-
- name: Cache node_modules
43-
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7
44-
with:
45-
path: node_modules
46-
key: ${{ runner.os }}-node_modules-${{ hashFiles('package*.json') }}
47-
48-
- name: Setup node
49-
uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516
50-
with:
51-
node-version: '16.17.0'
52-
cache: npm
53-
54-
- name: Install dependencies
55-
run: npm install --prefer-offline --no-audit --ignore-scripts
42+
- uses: ./.github/actions/node-npm-setup
5643

5744
- name: Run linter
5845
run: npm run lint

.github/workflows/enterprise-dates.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,7 @@ jobs:
3838
- name: Checkout repository code
3939
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
4040

41-
- name: Setup Node
42-
uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516
43-
with:
44-
node-version: '16.17.0'
45-
cache: npm
46-
47-
- name: Install Node.js dependencies
48-
run: npm ci
41+
- uses: ./.github/actions/node-npm-setup
4942

5043
- name: Run script/update-enterprise-dates.js
5144
run: |

.github/workflows/keep-caches-warm.yml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,7 @@ jobs:
2323
- name: Check out repo
2424
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
2525

26-
- name: Cache node_modules
27-
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7
28-
with:
29-
path: node_modules
30-
key: ${{ runner.os }}-node_modules-${{ hashFiles('package*.json') }}
31-
32-
- name: Setup node
33-
uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516
34-
with:
35-
node-version: '16.17.0'
36-
cache: npm
37-
38-
- name: Install dependencies
39-
run: npm install --prefer-offline --no-audit --ignore-scripts
26+
- uses: ./.github/actions/node-npm-setup
4027

4128
- name: Cache nextjs build
4229
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7

.github/workflows/link-check-daily.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,8 @@ jobs:
2424

2525
- name: Check out repo's default branch
2626
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
27-
- name: Setup Node
28-
uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516
29-
with:
30-
node-version: '16.17.0'
31-
cache: npm
3227

33-
- name: Install dependencies
34-
run: npm ci
28+
- uses: ./.github/actions/node-npm-setup
3529

3630
- name: Figure out which docs-early-access branch to checkout, if internal repo
3731
if: ${{ github.repository == 'github/docs-internal' }}

.github/workflows/link-check-on-pr.yml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,7 @@ jobs:
2828
- name: Checkout
2929
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
3030

31-
- name: Cache node_modules
32-
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7
33-
with:
34-
path: node_modules
35-
key: ${{ runner.os }}-node_modules-${{ hashFiles('package*.json') }}
36-
37-
- name: Setup node
38-
uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516
39-
with:
40-
node-version: '16.17.0'
41-
cache: npm
42-
43-
- name: Install dependencies
44-
run: npm install --prefer-offline --no-audit --ignore-scripts
31+
- uses: ./.github/actions/node-npm-setup
4532

4633
- name: Figure out which docs-early-access branch to checkout, if internal repo
4734
if: ${{ github.repository == 'github/docs-internal' }}

.github/workflows/manually-purge-fastly.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ jobs:
1818
- name: Check out repo
1919
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
2020

21-
- name: Install dependencies
22-
run: npm ci
21+
- uses: ./.github/actions/node-npm-setup
2322

2423
- name: Soft-purge Fastly cache
2524
env:

.github/workflows/open-enterprise-issue.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,7 @@ jobs:
2121
- name: Checkout repository code
2222
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
2323

24-
- name: Setup Node
25-
uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516
26-
with:
27-
node-version: '16.17.0'
28-
cache: npm
29-
30-
- name: Install dependencies
31-
run: npm ci
24+
- uses: ./.github/actions/node-npm-setup
3225

3326
- name: Check for existing release or deprecation issues
3427
id: existingIssue

.github/workflows/openapi-decorate.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,7 @@ jobs:
4545
# CI in the PR. (Events from GITHUB_TOKEN don't trigger new workflows.)
4646
token: ${{ secrets.DOCUBOT_REPO_PAT }}
4747

48-
- name: Setup node
49-
uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516
50-
with:
51-
node-version: '16.17.0'
52-
cache: npm
53-
54-
- name: Install dependencies
55-
run: npm ci
48+
- uses: ./.github/actions/node-npm-setup
5649

5750
- name: Decorate the dereferenced OpenAPI schemas
5851
run: script/rest/update-files.js --decorate-only

0 commit comments

Comments
 (0)