Skip to content

Commit 8e9303a

Browse files
committed
DRY GHA workflows
1 parent 01eef2b commit 8e9303a

File tree

6 files changed

+69
-128
lines changed

6 files changed

+69
-128
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: "Setup Node.js and pnpm"
2+
description: "Sets up Node.js and pnpm with caching and installs dependencies"
3+
4+
inputs:
5+
node-version:
6+
description: "Node.js version to use"
7+
required: false
8+
default: "20.19.2"
9+
pnpm-version:
10+
description: "pnpm version to use"
11+
required: false
12+
default: "10.8.1"
13+
skip-checkout:
14+
description: "Skip checkout step if already done"
15+
required: false
16+
default: "false"
17+
skip-install:
18+
description: "Skip dependency installation"
19+
required: false
20+
default: "false"
21+
install-args:
22+
description: "Additional arguments for pnpm install"
23+
required: false
24+
default: ""
25+
26+
runs:
27+
using: "composite"
28+
steps:
29+
- name: Checkout code
30+
if: ${{ inputs.skip-checkout != 'true' }}
31+
uses: actions/checkout@v4
32+
- name: Install pnpm
33+
uses: pnpm/action-setup@v4
34+
with:
35+
version: ${{ inputs.pnpm-version }}
36+
- name: Setup Node.js
37+
uses: actions/setup-node@v4
38+
with:
39+
node-version: ${{ inputs.node-version }}
40+
cache: "pnpm"
41+
- name: Install dependencies
42+
if: ${{ inputs.skip-install != 'true' }}
43+
shell: bash
44+
run: pnpm install ${{ inputs.install-args }}

.github/workflows/changeset-release.yml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ on:
99
env:
1010
REPO_PATH: ${{ github.repository }}
1111
GIT_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || 'main' }}
12-
NODE_VERSION: 20.19.2
13-
PNPM_VERSION: 10.8.1
1412

1513
jobs:
1614
# Job 1: Create version bump PR when changesets are merged to main
@@ -31,18 +29,10 @@ jobs:
3129
with:
3230
fetch-depth: 0
3331
ref: ${{ env.GIT_REF }}
34-
- name: Install pnpm
35-
uses: pnpm/action-setup@v4
32+
- name: Setup Node.js and pnpm
33+
uses: ./.github/actions/setup-node-pnpm
3634
with:
37-
version: ${{ env.PNPM_VERSION }}
38-
- name: Setup Node.js
39-
uses: actions/setup-node@v4
40-
with:
41-
node-version: ${{ env.NODE_VERSION }}
42-
cache: 'pnpm'
43-
44-
- name: Install Dependencies
45-
run: pnpm install
35+
skip-checkout: 'true'
4636

4737
# Check if there are any new changesets to process
4838
- name: Check for changesets

.github/workflows/code-qa.yml

Lines changed: 10 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -8,65 +8,28 @@ on:
88
types: [opened, reopened, ready_for_review, synchronize]
99
branches: [main]
1010

11-
env:
12-
NODE_VERSION: 20.19.2
13-
PNPM_VERSION: 10.8.1
14-
1511
jobs:
1612
check-translations:
1713
runs-on: ubuntu-latest
1814
steps:
19-
- name: Checkout code
20-
uses: actions/checkout@v4
21-
- name: Install pnpm
22-
uses: pnpm/action-setup@v4
23-
with:
24-
version: ${{ env.PNPM_VERSION }}
25-
- name: Setup Node.js
26-
uses: actions/setup-node@v4
27-
with:
28-
node-version: ${{ env.NODE_VERSION }}
29-
cache: 'pnpm'
30-
- name: Install dependencies
31-
run: pnpm install
15+
- name: Setup Node.js and pnpm
16+
uses: ./.github/actions/setup-node-pnpm
3217
- name: Verify all translations are complete
3318
run: node scripts/find-missing-translations.js
3419

3520
knip:
3621
runs-on: ubuntu-latest
3722
steps:
38-
- name: Checkout code
39-
uses: actions/checkout@v4
40-
- name: Install pnpm
41-
uses: pnpm/action-setup@v4
42-
with:
43-
version: ${{ env.PNPM_VERSION }}
44-
- name: Setup Node.js
45-
uses: actions/setup-node@v4
46-
with:
47-
node-version: ${{ env.NODE_VERSION }}
48-
cache: 'pnpm'
49-
- name: Install dependencies
50-
run: pnpm install
23+
- name: Setup Node.js and pnpm
24+
uses: ./.github/actions/setup-node-pnpm
5125
- name: Run knip checks
5226
run: pnpm knip
5327

5428
compile:
5529
runs-on: ubuntu-latest
5630
steps:
57-
- name: Checkout code
58-
uses: actions/checkout@v4
59-
- name: Install pnpm
60-
uses: pnpm/action-setup@v4
61-
with:
62-
version: ${{ env.PNPM_VERSION }}
63-
- name: Setup Node.js
64-
uses: actions/setup-node@v4
65-
with:
66-
node-version: ${{ env.NODE_VERSION }}
67-
cache: 'pnpm'
68-
- name: Install dependencies
69-
run: pnpm install
31+
- name: Setup Node.js and pnpm
32+
uses: ./.github/actions/setup-node-pnpm
7033
- name: Lint
7134
run: pnpm lint
7235
- name: Check types
@@ -78,19 +41,8 @@ jobs:
7841
matrix:
7942
os: [ubuntu-latest, windows-latest]
8043
steps:
81-
- name: Checkout code
82-
uses: actions/checkout@v4
83-
- name: Install pnpm
84-
uses: pnpm/action-setup@v4
85-
with:
86-
version: ${{ env.PNPM_VERSION }}
87-
- name: Setup Node.js
88-
uses: actions/setup-node@v4
89-
with:
90-
node-version: ${{ env.NODE_VERSION }}
91-
cache: 'pnpm'
92-
- name: Install dependencies
93-
run: pnpm install
44+
- name: Setup Node.js and pnpm
45+
uses: ./.github/actions/setup-node-pnpm
9446
- name: Run unit tests
9547
run: pnpm test
9648

@@ -114,19 +66,8 @@ jobs:
11466
needs: [check-openrouter-api-key]
11567
if: needs.check-openrouter-api-key.outputs.exists == 'true'
11668
steps:
117-
- name: Checkout code
118-
uses: actions/checkout@v4
119-
- name: Install pnpm
120-
uses: pnpm/action-setup@v4
121-
with:
122-
version: ${{ env.PNPM_VERSION }}
123-
- name: Setup Node.js
124-
uses: actions/setup-node@v4
125-
with:
126-
node-version: ${{ env.NODE_VERSION }}
127-
cache: 'pnpm'
128-
- name: Install dependencies
129-
run: pnpm install
69+
- name: Setup Node.js and pnpm
70+
uses: ./.github/actions/setup-node-pnpm
13071
- name: Create .env.local file
13172
working-directory: apps/vscode-e2e
13273
run: echo "OPENROUTER_API_KEY=${{ secrets.OPENROUTER_API_KEY }}" > .env.local

.github/workflows/marketplace-publish.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ on:
77

88
env:
99
GIT_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || 'main' }}
10-
NODE_VERSION: 20.19.2
11-
PNPM_VERSION: 10.8.1
1210

1311
jobs:
1412
publish-extension:
@@ -25,17 +23,10 @@ jobs:
2523
uses: actions/checkout@v4
2624
with:
2725
ref: ${{ env.GIT_REF }}
28-
- name: Install pnpm
29-
uses: pnpm/action-setup@v4
26+
- name: Setup Node.js and pnpm
27+
uses: ./.github/actions/setup-node-pnpm
3028
with:
31-
version: ${{ env.PNPM_VERSION }}
32-
- name: Setup Node.js
33-
uses: actions/setup-node@v4
34-
with:
35-
node-version: ${{ env.NODE_VERSION }}
36-
cache: 'pnpm'
37-
- name: Install dependencies
38-
run: pnpm install
29+
skip-checkout: 'true'
3930
- name: Configure Git
4031
run: |
4132
git config user.name "github-actions[bot]"

.github/workflows/nightly-publish.yml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ on:
88
branches: [main]
99
workflow_dispatch: # Allows manual triggering.
1010

11-
env:
12-
NODE_VERSION: 20.19.2
13-
PNPM_VERSION: 10.8.1
14-
1511
jobs:
1612
publish-nightly:
1713
runs-on: ubuntu-latest
@@ -25,17 +21,11 @@ jobs:
2521
uses: actions/checkout@v4
2622
with:
2723
fetch-depth: 0
28-
- name: Install pnpm
29-
uses: pnpm/action-setup@v4
30-
with:
31-
version: ${{ env.PNPM_VERSION }}
32-
- name: Setup Node.js
33-
uses: actions/setup-node@v4
24+
- name: Setup Node.js and pnpm
25+
uses: ./.github/actions/setup-node-pnpm
3426
with:
35-
node-version: ${{ env.NODE_VERSION }}
36-
cache: 'pnpm'
37-
- name: Install dependencies
38-
run: pnpm install --frozen-lockfile
27+
skip-checkout: 'true'
28+
install-args: '--frozen-lockfile'
3929
- name: Forge numeric Nightly version
4030
id: version
4131
env:

.github/workflows/update-contributors.yml

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,21 @@ on:
44
push:
55
branches:
66
- main
7-
workflow_dispatch: # Allows manual triggering
8-
9-
env:
10-
NODE_VERSION: 20.19.2
11-
PNPM_VERSION: 10.8.1
7+
workflow_dispatch:
128

139
jobs:
1410
update-contributors:
1511
runs-on: ubuntu-latest
1612
permissions:
17-
contents: write # Needed for pushing changes
18-
pull-requests: write # Needed for creating PRs
13+
contents: write # Needed for pushing changes.
14+
pull-requests: write # Needed for creating PRs.
1915
steps:
20-
- name: Checkout code
21-
uses: actions/checkout@v4
22-
- name: Install pnpm
23-
uses: pnpm/action-setup@v4
24-
with:
25-
version: ${{ env.PNPM_VERSION }}
26-
- name: Setup Node.js
27-
uses: actions/setup-node@v4
28-
with:
29-
node-version: ${{ env.NODE_VERSION }}
30-
cache: 'pnpm'
16+
- name: Setup Node.js and pnpm
17+
uses: ./.github/actions/setup-node-pnpm
3118
- name: Disable Husky
3219
run: |
3320
echo "HUSKY=0" >> $GITHUB_ENV
3421
git config --global core.hooksPath /dev/null
35-
- name: Install dependencies
36-
run: pnpm install
3722
- name: Update contributors and format
3823
run: |
3924
pnpm update-contributors

0 commit comments

Comments
 (0)