Skip to content

Commit 13bc097

Browse files
authored
feat: update runtime to node 20 (#316)
* feat: update runtime to node 20 * fix jest exit code issue
1 parent 128d8b9 commit 13bc097

17 files changed

+110
-65
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- uses: actions/checkout@v4
1818
- uses: actions/setup-node@v4
1919
with:
20-
node-version: 16.x
20+
node-version: 20.x
2121
cache: npm
2222
- run: npm ci
2323
- run: npm run build

.github/workflows/hello-world-command.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
uses: peter-evans/create-or-update-comment@v4
1111
with:
1212
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
13-
reaction-type: hooray
13+
reactions: hooray
1414

1515
- name: Create URL to the run output
1616
id: vars

.github/workflows/ping-command.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ jobs:
1212
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
1313
body: |
1414
>pong ${{ github.event.client_payload.slash_command.args.all }}
15-
reaction-type: hooray
15+
reactions: hooray
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Update Major Version
2+
run-name: Update ${{ github.event.inputs.main_version }} to ${{ github.event.inputs.target }}
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
target:
8+
description: The target tag or reference
9+
required: true
10+
main_version:
11+
type: choice
12+
description: The major version tag to update
13+
options:
14+
- v4
15+
16+
jobs:
17+
tag:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
23+
fetch-depth: 0
24+
- name: Git config
25+
run: |
26+
git config user.name actions-bot
27+
git config user.email [email protected]
28+
- name: Tag new target
29+
run: git tag -f ${{ github.event.inputs.main_version }} ${{ github.event.inputs.target }}
30+
- name: Push new tag
31+
run: git push origin ${{ github.event.inputs.main_version }} --force

README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ See it in action with the following live demos.
3636
- [Standard configuration](#standard-configuration)
3737
- [Advanced configuration](docs/advanced-configuration.md)
3838
- [Workflow dispatch](docs/workflow-dispatch.md)
39-
- [Updating to v3](docs/updating.md)
39+
- [Updating to v4](docs/updating.md)
4040

4141
## Dispatching commands
4242

@@ -54,7 +54,7 @@ jobs:
5454
runs-on: ubuntu-latest
5555
steps:
5656
- name: Slash Command Dispatch
57-
uses: peter-evans/slash-command-dispatch@v3
57+
uses: peter-evans/slash-command-dispatch@v4
5858
with:
5959
token: ${{ secrets.PAT }}
6060
commands: |
@@ -102,7 +102,7 @@ You can use a [PAT](https://docs.github.com/en/github/authenticating-to-github/c
102102

103103
```yml
104104
- name: Slash Command Dispatch
105-
uses: peter-evans/slash-command-dispatch@v3
105+
uses: peter-evans/slash-command-dispatch@v4
106106
with:
107107
token: ${{ secrets.PAT }}
108108
reaction-token: ${{ secrets.PAT }}
@@ -178,7 +178,7 @@ It will also contain any static arguments if configured.
178178

179179
To demonstrate, take the following configuration as an example.
180180
```yml
181-
- uses: peter-evans/slash-command-dispatch@v3
181+
- uses: peter-evans/slash-command-dispatch@v4
182182
with:
183183
token: ${{ secrets.PAT }}
184184
commands: |
@@ -248,12 +248,12 @@ The simplest response is to add a :tada: reaction to the comment.
248248

249249
```yml
250250
- name: Add reaction
251-
uses: peter-evans/create-or-update-comment@v2
251+
uses: peter-evans/create-or-update-comment@v4
252252
with:
253253
token: ${{ secrets.PAT }}
254254
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
255255
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
256-
reaction-type: hooray
256+
reactions: hooray
257257
```
258258

259259
Another option is to reply with a new comment containing a link to the run output.
@@ -264,7 +264,7 @@ Another option is to reply with a new comment containing a link to the run outpu
264264
run: echo "run-url=https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_OUTPUT
265265
266266
- name: Create comment
267-
uses: peter-evans/create-or-update-comment@v2
267+
uses: peter-evans/create-or-update-comment@v4
268268
with:
269269
token: ${{ secrets.PAT }}
270270
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}

__test__/command-helper.unit.test.ts

+11-5
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ describe('command-helper tests', () => {
153153
dispatch_type: 'repository'
154154
}
155155
]
156-
expect(configIsValid(config)).toBeTruthy()
156+
expect(configIsValid(config)).toEqual(null)
157157
})
158158

159159
test('invalid permission level in config', async () => {
@@ -169,7 +169,9 @@ describe('command-helper tests', () => {
169169
dispatch_type: 'repository'
170170
}
171171
]
172-
expect(configIsValid(config)).toBeFalsy()
172+
expect(configIsValid(config)).toEqual(
173+
`'test-case-invalid-permission' is not a valid 'permission'.`
174+
)
173175
})
174176

175177
test('invalid issue type in config', async () => {
@@ -185,23 +187,27 @@ describe('command-helper tests', () => {
185187
dispatch_type: 'repository'
186188
}
187189
]
188-
expect(configIsValid(config)).toBeFalsy()
190+
expect(configIsValid(config)).toEqual(
191+
`'test-case-invalid-issue-type' is not a valid 'issue-type'.`
192+
)
189193
})
190194

191195
test('invalid dispatch type in config', async () => {
192196
const config: Command[] = [
193197
{
194198
command: 'test',
195199
permission: 'write',
196-
issue_type: 'test-case-invalid-issue-type',
200+
issue_type: 'both',
197201
allow_edits: false,
198202
repository: 'peter-evans/slash-command-dispatch',
199203
event_type_suffix: '-command',
200204
static_args: [],
201205
dispatch_type: 'test-case-invalid-dispatch-type'
202206
}
203207
]
204-
expect(configIsValid(config)).toBeFalsy()
208+
expect(configIsValid(config)).toEqual(
209+
`'test-case-invalid-dispatch-type' is not a valid 'dispatch-type'.`
210+
)
205211
})
206212

207213
test('actor does not have permission', async () => {

action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ outputs:
4141
error-message:
4242
description: 'Validation errors when using `workflow` dispatch.'
4343
runs:
44-
using: 'node16'
44+
using: 'node20'
4545
main: 'dist/index.js'
4646
branding:
4747
icon: 'target'

dist/index.js

+8-9
Original file line numberDiff line numberDiff line change
@@ -147,19 +147,16 @@ exports.getCommandsConfigFromJson = getCommandsConfigFromJson;
147147
function configIsValid(config) {
148148
for (const command of config) {
149149
if (!['none', 'read', 'triage', 'write', 'maintain', 'admin'].includes(command.permission)) {
150-
core.setFailed(`'${command.permission}' is not a valid 'permission'.`);
151-
return false;
150+
return `'${command.permission}' is not a valid 'permission'.`;
152151
}
153152
if (!['issue', 'pull-request', 'both'].includes(command.issue_type)) {
154-
core.setFailed(`'${command.issue_type}' is not a valid 'issue-type'.`);
155-
return false;
153+
return `'${command.issue_type}' is not a valid 'issue-type'.`;
156154
}
157155
if (!['repository', 'workflow'].includes(command.dispatch_type)) {
158-
core.setFailed(`'${command.dispatch_type}' is not a valid 'dispatch-type'.`);
159-
return false;
156+
return `'${command.dispatch_type}' is not a valid 'dispatch-type'.`;
160157
}
161158
}
162-
return true;
159+
return null;
163160
}
164161
exports.configIsValid = configIsValid;
165162
function actorHasPermission(actorPermission, commandPermission) {
@@ -454,8 +451,10 @@ function run() {
454451
const config = (0, command_helper_1.getCommandsConfig)(inputs);
455452
core.debug(`Commands config: ${(0, util_1.inspect)(config)}`);
456453
// Check the config is valid
457-
if (!(0, command_helper_1.configIsValid)(config))
458-
return;
454+
const configError = (0, command_helper_1.configIsValid)(config);
455+
if (configError) {
456+
throw new Error(configError);
457+
}
459458
// Get the comment body and id
460459
const commentBody = github.context.payload.comment.body;
461460
const commentId = github.context.payload.comment.id;

docs/advanced-configuration.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ For example, the following basic configuration means that all commands must have
88

99
```yml
1010
- name: Slash Command Dispatch
11-
uses: peter-evans/slash-command-dispatch@v3
11+
uses: peter-evans/slash-command-dispatch@v4
1212
with:
1313
token: ${{ secrets.PAT }}
1414
commands: |
@@ -38,7 +38,7 @@ jobs:
3838
runs-on: ubuntu-latest
3939
steps:
4040
- name: Slash Command Dispatch
41-
uses: peter-evans/slash-command-dispatch@v3
41+
uses: peter-evans/slash-command-dispatch@v4
4242
with:
4343
token: ${{ secrets.PAT }}
4444
config: >
@@ -84,7 +84,7 @@ jobs:
8484
steps:
8585
- uses: actions/checkout@v3
8686
- name: Slash Command Dispatch
87-
uses: peter-evans/slash-command-dispatch@v3
87+
uses: peter-evans/slash-command-dispatch@v4
8888
with:
8989
token: ${{ secrets.PAT }}
9090
config-from-file: .github/slash-command-dispatch.json

docs/examples.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ jobs:
5050
5151
# Add reaction to the comment
5252
- name: Add reaction
53-
uses: peter-evans/create-or-update-comment@v2
53+
uses: peter-evans/create-or-update-comment@v4
5454
with:
5555
token: ${{ secrets.PAT }}
5656
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
5757
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
58-
reaction-type: hooray
58+
reactions: hooray
5959
```
6060
6161
### pytest
@@ -111,12 +111,12 @@ jobs:
111111

112112
# Add reaction to the comment
113113
- name: Add reaction
114-
uses: peter-evans/create-or-update-comment@v2
114+
uses: peter-evans/create-or-update-comment@v4
115115
with:
116116
token: ${{ secrets.PAT }}
117117
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
118118
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
119-
reaction-type: hooray
119+
reactions: hooray
120120
```
121121
122122
## Use case: Execute command to modify a pull request branch
@@ -158,12 +158,12 @@ jobs:
158158
git push
159159
160160
- name: Add reaction
161-
uses: peter-evans/create-or-update-comment@v2
161+
uses: peter-evans/create-or-update-comment@v4
162162
with:
163163
token: ${{ secrets.PAT }}
164164
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
165165
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
166-
reaction-type: hooray
166+
reactions: hooray
167167
```
168168
169169
### rebase
@@ -204,28 +204,28 @@ jobs:
204204
git push --force-with-lease
205205
206206
- name: Update comment
207-
uses: peter-evans/create-or-update-comment@v2
207+
uses: peter-evans/create-or-update-comment@v4
208208
with:
209209
token: ${{ secrets.PAT }}
210210
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
211211
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
212212
body: |
213213
>Pull request successfully rebased
214-
reaction-type: hooray
214+
reactions: hooray
215215

216216
notRebaseable:
217217
if: github.event.client_payload.pull_request.rebaseable != true
218218
runs-on: ubuntu-latest
219219
steps:
220220
- name: Update comment
221-
uses: peter-evans/create-or-update-comment@v2
221+
uses: peter-evans/create-or-update-comment@v4
222222
with:
223223
token: ${{ secrets.PAT }}
224224
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
225225
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
226226
body: |
227227
>Pull request is not rebaseable
228-
reaction-type: hooray
228+
reactions: hooray
229229
```
230230
231231
### black
@@ -279,12 +279,12 @@ jobs:
279279
git push
280280
281281
- name: Add reaction
282-
uses: peter-evans/create-or-update-comment@v2
282+
uses: peter-evans/create-or-update-comment@v4
283283
with:
284284
token: ${{ secrets.PAT }}
285285
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
286286
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
287-
reaction-type: hooray
287+
reactions: hooray
288288
```
289289
290290
## Help command
@@ -301,7 +301,7 @@ jobs:
301301
runs-on: ubuntu-latest
302302
steps:
303303
- name: Update comment
304-
uses: peter-evans/create-or-update-comment@v2
304+
uses: peter-evans/create-or-update-comment@v4
305305
with:
306306
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
307307
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
@@ -313,5 +313,5 @@ jobs:
313313
> /ping [\<args\> ...] | Echos back a list of arguments
314314
> /hello-world-local | Receive a greeting from the world (local execution)
315315
> /ping-local [\<args\> ...] | Echos back a list of arguments (local execution)
316-
reaction-type: hooray
316+
reactions: hooray
317317
```

docs/getting-started.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ Follow this guide to get started with a working `/example` command.
1919
runs-on: ubuntu-latest
2020
steps:
2121
- name: Add reaction
22-
uses: peter-evans/create-or-update-comment@v2
22+
uses: peter-evans/create-or-update-comment@v4
2323
with:
2424
token: ${{ secrets.PAT }}
2525
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
2626
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
27-
reaction-type: hooray
27+
reactions: hooray
2828
```
2929
3030
3. Create a `repo` scoped Personal Access Token (PAT) by following [this guide](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token).
@@ -56,7 +56,7 @@ Command processing setup is complete! Now we need to setup command dispatch for
5656
runs-on: ubuntu-latest
5757
steps:
5858
- name: Slash Command Dispatch
59-
uses: peter-evans/slash-command-dispatch@v3
59+
uses: peter-evans/slash-command-dispatch@v4
6060
with:
6161
token: ${{ secrets.PAT }}
6262
commands: example

docs/updating.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
1-
## Updating from `v2` to `v3`
1+
## Updating from `v3` to `v4`
22

33
### Breaking changes
44

55
- If using self-hosted runners or GitHub Enterprise Server, there are minimum requirements for `v4` to run. See "What's new" below for details.
66

77
### What's new
88

9+
- Updated runtime to Node.js 20
10+
- The action now requires a minimum version of [v2.308.0](https://github.com/actions/runner/releases/tag/v2.308.0) for the Actions runner. Update self-hosted runners to v2.308.0 or later to ensure compatibility.
11+
12+
## Updating from `v2` to `v3`
13+
14+
### Breaking changes
15+
16+
- If using self-hosted runners or GitHub Enterprise Server, there are minimum requirements for `v3` to run. See "What's new" below for details.
17+
18+
### What's new
19+
920
- Updated runtime to Node.js 16
1021
- The action now requires a minimum version of v2.285.0 for the [Actions Runner](https://github.com/actions/runner/releases/tag/v2.285.0).
1122
- If using GitHub Enterprise Server, the action requires [GHES 3.4](https://docs.github.com/en/[email protected]/admin/release-notes) or later.

0 commit comments

Comments
 (0)