Skip to content

Commit 5b5e8f6

Browse files
authored
ci: update workflows (#64)
1 parent dd1973e commit 5b5e8f6

File tree

6 files changed

+81
-46
lines changed

6 files changed

+81
-46
lines changed

.github/workflows/check-dist.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ jobs:
2929
- name: Checkout
3030
id: checkout
3131
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
32+
with:
33+
persist-credentials: false
3234

3335
- name: Setup Node.js
3436
id: setup-node

.github/workflows/ci.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,24 @@ on:
55
push:
66
branches:
77
- main
8-
- 'releases/*'
8+
workflow_call:
99
schedule:
1010
- cron: '0 22 * * 2'
1111

12-
permissions:
13-
contents: read
12+
permissions: {}
1413

1514
jobs:
1615
test-typescript:
1716
name: TypeScript Tests
1817
runs-on: ubuntu-latest
19-
18+
permissions:
19+
contents: read
2020
steps:
2121
- name: Checkout
2222
id: checkout
2323
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
24+
with:
25+
persist-credentials: false
2426

2527
- name: Setup Node.js
2628
id: setup-node
@@ -44,3 +46,12 @@ jobs:
4446
- name: Test
4547
id: npm-ci-test
4648
run: npm run ci-test
49+
50+
integration-tests:
51+
if: ${{ github.ref == 'refs/heads/main' }}
52+
needs: test-typescript
53+
uses: ./.github/workflows/integration-tests.yml
54+
permissions:
55+
contents: write
56+
secrets:
57+
GH_APP_CREDS: ${{ secrets.GH_APP_CREDS }}

.github/workflows/codeql-analysis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ jobs:
3131
- name: Checkout
3232
id: checkout
3333
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
34+
with:
35+
persist-credentials: false
3436

3537
- name: Initialize CodeQL
3638
id: initialize

.github/workflows/integration-tests.yml

Lines changed: 48 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,24 @@
11
name: Integration Tests
22

33
on:
4+
workflow_call:
45
workflow_dispatch:
5-
workflow_run:
6-
workflows: ['CI']
7-
branches:
8-
- main
9-
- 'releases/*'
10-
types:
11-
- completed
12-
schedule:
13-
- cron: '0 22 * * 3'
14-
15-
permissions:
16-
contents: read
6+
7+
permissions: {}
178

189
jobs:
1910
integration-tests:
2011
name: Integration Test
2112
runs-on: ubuntu-latest
2213
permissions:
2314
contents: write
24-
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
2515

2616
steps:
2717
- name: Checkout
2818
id: checkout
2919
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
20+
with:
21+
persist-credentials: false
3022

3123
- name: Make note of the branch name
3224
id: branch-name
@@ -61,13 +53,18 @@ jobs:
6153

6254
- name: Confirm new ref commit
6355
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
56+
env:
57+
MESSAGE: ${{ steps.commit-new-ref.outputs.message }}
58+
REF: ${{ steps.commit-new-ref.outputs.ref }}
59+
REF_OPERATION: ${{ steps.commit-new-ref.outputs.ref-operation }}
60+
SHA: ${{ steps.commit-new-ref.outputs.sha }}
6461
with:
6562
github-token: ${{ steps.generate-token.outputs.token }}
6663
script: |
6764
const assert = require('node:assert');
6865
6966
const message = 'Test new ref commit';
70-
const refs = ['integration-test-playground-${{ github.run_id }}-${{ github.run_number }}', '${{ steps.commit-new-ref.outputs.sha }}'];
67+
const refs = ['integration-test-playground-${{ github.run_id }}-${{ github.run_number }}', process.env.SHA];
7168
7269
// Fetch the commit by both ref and sha
7370
for (const ref of refs) {
@@ -77,10 +74,10 @@ jobs:
7774
ref,
7875
});
7976
80-
assert.strictEqual('${{ steps.commit-new-ref.outputs.message }}', message, 'Expected correct message output');
81-
assert.strictEqual('${{ steps.commit-new-ref.outputs.ref }}', refs[0], 'Expected correct ref output');
82-
assert.strictEqual('${{ steps.commit-new-ref.outputs.ref-operation }}', 'created', 'Expected correct ref operation');
83-
assert.strictEqual(data.sha, '${{ steps.commit-new-ref.outputs.sha }}', 'Expected sha for commit to match');
77+
assert.strictEqual(process.env.MESSAGE, message, 'Expected correct message output');
78+
assert.strictEqual(process.env.REF, refs[0], 'Expected correct ref output');
79+
assert.strictEqual(process.env.REF_OPERATION, 'created', 'Expected correct ref operation');
80+
assert.strictEqual(data.sha, process.env.SHA, 'Expected sha for commit to match');
8481
assert.strictEqual(data.commit.message, message, 'Expected commit message to match');
8582
assert.strictEqual(data.commit.verification.verified, true, 'Expected commit to be verified');
8683
@@ -121,13 +118,18 @@ jobs:
121118

122119
- name: Confirm existing ref commit
123120
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
121+
env:
122+
MESSAGE: ${{ steps.update-existing-ref.outputs.message }}
123+
REF: ${{ steps.update-existing-ref.outputs.ref }}
124+
REF_OPERATION: ${{ steps.update-existing-ref.outputs.ref-operation }}
125+
SHA: ${{ steps.update-existing-ref.outputs.sha }}
124126
with:
125127
github-token: ${{ steps.generate-token.outputs.token }}
126128
script: |
127129
const assert = require('node:assert');
128130
129131
const message = 'Test updating existing ref';
130-
const refs = ['integration-test-playground-${{ github.run_id }}-${{ github.run_number }}', '${{ steps.update-existing-ref.outputs.sha }}'];
132+
const refs = ['integration-test-playground-${{ github.run_id }}-${{ github.run_number }}', process.env.SHA];
131133
132134
// Fetch the commit by both ref and sha
133135
for (const ref of refs) {
@@ -137,10 +139,10 @@ jobs:
137139
ref,
138140
});
139141
140-
assert.strictEqual('${{ steps.update-existing-ref.outputs.message }}', message, 'Expected correct message output');
141-
assert.strictEqual('${{ steps.update-existing-ref.outputs.ref }}', refs[0], 'Expected correct ref output');
142-
assert.strictEqual('${{ steps.update-existing-ref.outputs.ref-operation }}', 'updated', 'Expected correct ref operation');
143-
assert.strictEqual(data.sha, '${{ steps.update-existing-ref.outputs.sha }}', 'Expected sha for commit to match');
142+
assert.strictEqual(process.env.MESSAGE, message, 'Expected correct message output');
143+
assert.strictEqual(process.env.REF, refs[0], 'Expected correct ref output');
144+
assert.strictEqual(process.env.REF_OPERATION, 'updated', 'Expected correct ref operation');
145+
assert.strictEqual(data.sha, process.env.SHA, 'Expected sha for commit to match');
144146
assert.strictEqual(data.commit.message, message, 'Expected commit message to match');
145147
assert.strictEqual(data.commit.verification.verified, true, 'Expected commit to be verified');
146148
}
@@ -163,13 +165,18 @@ jobs:
163165

164166
- name: Confirm existing ref commit
165167
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
168+
env:
169+
MESSAGE: ${{ steps.update-existing-ref-2.outputs.message }}
170+
REF: ${{ steps.update-existing-ref-2.outputs.ref }}
171+
REF_OPERATION: ${{ steps.update-existing-ref-2.outputs.ref-operation }}
172+
SHA: ${{ steps.update-existing-ref-2.outputs.sha }}
166173
with:
167174
github-token: ${{ steps.generate-token.outputs.token }}
168175
script: |
169176
const assert = require('node:assert');
170177
171178
const message = 'Test updating existing ref (again)';
172-
const refs = ['integration-test-playground-${{ github.run_id }}-${{ github.run_number }}', '${{ steps.update-existing-ref-2.outputs.sha }}'];
179+
const refs = ['integration-test-playground-${{ github.run_id }}-${{ github.run_number }}', process.env.SHA];
173180
174181
// Fetch the commit by both ref and sha
175182
for (const ref of refs) {
@@ -179,10 +186,10 @@ jobs:
179186
ref,
180187
});
181188
182-
assert.strictEqual('${{ steps.update-existing-ref-2.outputs.message }}', message, 'Expected correct message output');
183-
assert.strictEqual('${{ steps.update-existing-ref-2.outputs.ref }}', refs[0], 'Expected correct ref output');
184-
assert.strictEqual('${{ steps.update-existing-ref-2.outputs.ref-operation }}', 'updated', 'Expected correct ref operation');
185-
assert.strictEqual(data.sha, '${{ steps.update-existing-ref-2.outputs.sha }}', 'Expected sha for commit to match');
189+
assert.strictEqual(process.env.MESSAGE, message, 'Expected correct message output');
190+
assert.strictEqual(process.env.REF, refs[0], 'Expected correct ref output');
191+
assert.strictEqual(process.env.REF_OPERATION, 'updated', 'Expected correct ref operation');
192+
assert.strictEqual(data.sha, process.env.SHA, 'Expected sha for commit to match');
186193
assert.strictEqual(data.commit.message, message, 'Expected commit message to match');
187194
assert.strictEqual(data.commit.verification.verified, true, 'Expected commit to be verified');
188195
}
@@ -202,7 +209,9 @@ jobs:
202209
token: ${{ steps.generate-token.outputs.token }}
203210

204211
- name: Switch back to base branch
205-
run: git switch ${{ steps.branch-name.outputs.BRANCH }}
212+
env:
213+
BRANCH: ${{ steps.branch-name.outputs.BRANCH }}
214+
run: git switch $BRANCH
206215

207216
- name: Make changes to commit and stage them
208217
run: |
@@ -220,13 +229,18 @@ jobs:
220229

221230
- name: Confirm forced commit
222231
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
232+
env:
233+
MESSAGE: ${{ steps.force-update-existing-ref.outputs.message }}
234+
REF: ${{ steps.force-update-existing-ref.outputs.ref }}
235+
REF_OPERATION: ${{ steps.force-update-existing-ref.outputs.ref-operation }}
236+
SHA: ${{ steps.force-update-existing-ref.outputs.sha }}
223237
with:
224238
github-token: ${{ steps.generate-token.outputs.token }}
225239
script: |
226240
const assert = require('node:assert');
227241
228242
const message = 'Test updating existing ref (force)';
229-
const refs = ['integration-test-playground-${{ github.run_id }}-${{ github.run_number }}', '${{ steps.force-update-existing-ref.outputs.sha }}'];
243+
const refs = ['integration-test-playground-${{ github.run_id }}-${{ github.run_number }}', process.env.SHA];
230244
231245
// Fetch the commit by both ref and sha
232246
for (const ref of refs) {
@@ -236,10 +250,10 @@ jobs:
236250
ref,
237251
});
238252
239-
assert.strictEqual('${{ steps.force-update-existing-ref.outputs.message }}', message, 'Expected correct message output');
240-
assert.strictEqual('${{ steps.force-update-existing-ref.outputs.ref }}', refs[0], 'Expected correct ref output');
241-
assert.strictEqual('${{ steps.force-update-existing-ref.outputs.ref-operation }}', 'updated', 'Expected correct ref operation');
242-
assert.strictEqual(data.sha, '${{ steps.force-update-existing-ref.outputs.sha }}', 'Expected sha for commit to match');
253+
assert.strictEqual(process.env.MESSAGE, message, 'Expected correct message output');
254+
assert.strictEqual(process.env.REF, refs[0], 'Expected correct ref output');
255+
assert.strictEqual(process.env.REF_OPERATION, 'updated', 'Expected correct ref operation');
256+
assert.strictEqual(data.sha, process.env.SHA, 'Expected sha for commit to match');
243257
assert.strictEqual(data.commit.message, message, 'Expected commit message to match');
244258
assert.strictEqual(data.commit.verification.verified, true, 'Expected commit to be verified');
245259
}

.github/workflows/linter.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
2525
with:
2626
fetch-depth: 0
27+
persist-credentials: false
2728

2829
- name: Setup Node.js
2930
id: setup-node

.github/workflows/release.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,36 @@
11
name: Release
22

33
on:
4-
workflow_run:
5-
workflows: ['Integration Tests']
4+
push:
65
branches:
76
- main
8-
- 'releases/*'
9-
types:
10-
- completed
117

12-
permissions:
13-
contents: read
8+
permissions: {}
149

1510
jobs:
11+
ci:
12+
uses: ./.github/workflows/ci.yml
13+
permissions:
14+
contents: write
15+
secrets:
16+
GH_APP_CREDS: ${{ secrets.GH_APP_CREDS }}
17+
1618
release:
1719
name: release
1820
runs-on: ubuntu-latest
19-
if: ${{ github.event.workflow_run.conclusion == 'success' }}
21+
needs: ci
2022
permissions:
2123
contents: write
2224
steps:
2325
- name: Checkout
2426
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
27+
with:
28+
persist-credentials: false
2529
- name: Setup Node.js
2630
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
2731
with:
2832
node-version: 20
33+
package-cache-manager: false
2934
- run: npm install --save-dev semantic-release-major-tag
3035
- run: npx semantic-release
3136
env:

0 commit comments

Comments
 (0)