README for updating actions/github-script from v7 to v8 · actions/github-script@adc0eea (original) (raw)

`@@ -53,6 +53,12 @@ documentation.

`

53

53

``

54

54

`## Breaking Changes

`

55

55

``

``

56

`+

V8

`

``

57

+

``

58

`+

Version 8 of this action updated the runtime to Node 24 - https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runs-for-javascript-actions

`

``

59

+

``

60

`+

All scripts are now run with Node 24 instead of Node 20 and are affected by any breaking changes between Node 20 and 24.

`

``

61

+

56

62

`### V7

`

57

63

``

58

64

`Version 7 of this action updated the runtime to Node 20 - https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runs-for-javascript-actions

`

`` @@ -91,7 +97,7 @@ and potential SyntaxErrors when the expression is not valid JavaScript code (p

``

91

97

`` To pass inputs, set env vars on the action step and reference them in your script with process.env:

``

92

98

``

93

99

```` ```yaml


`94`

``

`-

- uses: actions/github-script@v7

`

``

`100`

`+

- uses: actions/github-script@v8

`

`95`

`101`

`env:

`

`96`

`102`

`TITLE: ${{ github.event.pull_request.title }}

`

`97`

`103`

`with:

`

`@@ -110,7 +116,7 @@ The return value of the script will be in the step's outputs under the

`

`110`

`116`

`"result" key.

`

`111`

`117`

``

`112`

`118`

```` ```yaml

113

``

`-

`

``

119

`+

`

114

120

`id: set-result

`

115

121

`with:

`

116

122

`script: return "Hello!"

`

`@@ -129,7 +135,7 @@ output of a github-script step. For some workflows, string encoding is preferred

`

129

135

`` result-encoding input:

``

130

136

``

131

137

```` ```yaml


`132`

``

`-

- uses: actions/github-script@v7

`

``

`138`

`+

- uses: actions/github-script@v8

`

`133`

`139`

` id: my-script

`

`134`

`140`

` with:

`

`135`

`141`

` result-encoding: string

`

`@@ -141,7 +147,7 @@ output of a github-script step. For some workflows, string encoding is preferred

`

`141`

`147`

`` By default, requests made with the `github` instance will not be retried. You can configure this with the `retries` option:

``

`142`

`148`

``

`143`

`149`

```` ```yaml

144

``

`-

`

``

150

`+

`

145

151

` id: my-script

`

146

152

` with:

`

147

153

` result-encoding: string

`

`` @@ -159,7 +165,7 @@ In this example, request failures from github.rest.issues.get() will be retrie

``

159

165

`` You can also configure which status codes should be exempt from retries via the retry-exempt-status-codes option:

``

160

166

``

161

167

```` ```yaml


`162`

``

`-

- uses: actions/github-script@v7

`

``

`168`

`+

- uses: actions/github-script@v8

`

`163`

`169`

` id: my-script

`

`164`

`170`

` with:

`

`165`

`171`

` result-encoding: string

`

`@@ -188,7 +194,7 @@ By default, github-script will use the token provided to your workflow.

`

`188`

`194`

``

`189`

`195`

```` ```yaml

190

196

`- name: View context attributes

`

191

``

`-

uses: actions/github-script@v7

`

``

197

`+

uses: actions/github-script@v8

`

192

198

` with:

`

193

199

` script: console.log(context)

`

194

200

```` ```

````

`@@ -204,7 +210,7 @@ jobs:

`

204

210

` comment:

`

205

211

` runs-on: ubuntu-latest

`

206

212

` steps:

`

207

``

`-

`

``

213

`+

`

208

214

` with:

`

209

215

` script: |

`

210

216

` github.rest.issues.createComment({

`

`@@ -226,7 +232,7 @@ jobs:

`

226

232

` apply-label:

`

227

233

` runs-on: ubuntu-latest

`

228

234

` steps:

`

229

``

`-

`

``

235

`+

`

230

236

` with:

`

231

237

` script: |

`

232

238

` github.rest.issues.addLabels({

`

`@@ -248,7 +254,7 @@ jobs:

`

248

254

` welcome:

`

249

255

` runs-on: ubuntu-latest

`

250

256

` steps:

`

251

``

`-

`

``

257

`+

`

252

258

` with:

`

253

259

` script: |

`

254

260

` // Get a list of all issues created by the PR opener

`

`@@ -293,7 +299,7 @@ jobs:

`

293

299

`diff:

`

294

300

`runs-on: ubuntu-latest

`

295

301

`steps:

`

296

``

`-

`

``

302

`+

`

297

303

`with:

`

298

304

`script: |

`

299

305

` const diff_url = context.payload.pull_request.diff_url

`

`@@ -317,7 +323,7 @@ jobs:

`

317

323

` list-issues:

`

318

324

` runs-on: ubuntu-latest

`

319

325

` steps:

`

320

``

`-

`

``

326

`+

`

321

327

` with:

`

322

328

` script: |

`

323

329

`` const query = `query($owner:String!, name:String!,name:String!, name:String!,label:String!) {

``

`@@ -351,7 +357,7 @@ jobs:

`

351

357

`runs-on: ubuntu-latest

`

352

358

`steps:

`

353

359

` - uses: actions/checkout@v4

`

354

``

`-

`

``

360

`+

`

355

361

`with:

`

356

362

`script: |

`

357

363

` const script = require('./path/to/script.js')

`

`@@ -389,7 +395,7 @@ jobs:

`

389

395

`runs-on: ubuntu-latest

`

390

396

`steps:

`

391

397

` - uses: actions/checkout@v4

`

392

``

`-

`

``

398

`+

`

393

399

`env:

`

394

400

`SHA: '${{env.parentSHA}}'

`

395

401

`with:

`

`@@ -433,7 +439,7 @@ jobs:

`

433

439

` - run: npm ci

`

434

440

`# or one-off:

`

435

441

` - run: npm install execa

`

436

``

`-

`

``

442

`+

`

437

443

`with:

`

438

444

`script: |

`

439

445

` const execa = require('execa')

`

`@@ -463,7 +469,7 @@ jobs:

`

463

469

` runs-on: ubuntu-latest

`

464

470

` steps:

`

465

471

` - uses: actions/checkout@v4

`

466

``

`-

`

``

472

`+

`

467

473

` with:

`

468

474

` script: |

`

469

475

` const { default: printStuff } = await import('${{ github.workspace }}/src/print-stuff.js')

`

`@@ -507,7 +513,7 @@ jobs:

`

507

513

` apply-label:

`

508

514

` runs-on: ubuntu-latest

`

509

515

` steps:

`

510

``

`-

`

``

516

`+

`

511

517

` with:

`

512

518

` github-token: ${{ secrets.MY_PAT }}

`

513

519

` script: |

`

`@@ -531,7 +537,7 @@ jobs:

`

531

537

` runs-on: ubuntu-latest

`

532

538

` steps:

`

533

539

` - uses: actions/checkout@v4

`

534

``

`-

`

``

540

`+

`

535

541

` with:

`

536

542

` script: |

`

537

543

` const exitCode = await exec.exec('echo', ['hello'])

`

`@@ -549,7 +555,7 @@ jobs:

`

549

555

` runs-on: ubuntu-latest

`

550

556

` steps:

`

551

557

` - uses: actions/checkout@v4

`

552

``

`-

`

``

558

`+

`

553

559

` with:

`

554

560

` script: |

`

555

561

` const {

`