@@ -18,18 +18,12 @@ arguments will be provided:
18
18
- ` core ` A reference to the [ @actions/core ] ( https://github.com/actions/toolkit/tree/main/packages/core ) package
19
19
- ` glob ` A reference to the [ @actions/glob ] ( https://github.com/actions/toolkit/tree/main/packages/glob ) package
20
20
- ` io ` A reference to the [ @actions/io ] ( https://github.com/actions/toolkit/tree/main/packages/io ) package
21
- - ` require ` Is available, with some caveats:
22
- - The location of the module that runs this action is where the Actions
23
- runner downloads the github-script action to, so the ` require ` passed to
24
- your script is actually a proxy that intercepts calls to require relative
25
- paths and transforms them into an absolute path in the working directory,
26
- instead.
27
- - If you want to require an npm module in your working directory, you still
28
- need to specify the relative path, including ` node_modules ` , such as
29
- ` ./node_modules/lodash ` .
30
- - If for some reason you need the non-wrapped ` require ` , there is an escape
31
- hatch available: ` __original_require__ ` is the original value of ` require `
32
- without our wrapping applied.
21
+ - ` require ` A proxy wrapper around the normal Node.js ` require ` to enable
22
+ requiring relative paths (relative to the current working directory) and
23
+ requiring npm packages installed in the current working directory. If for
24
+ some reason you need the non-wrapped ` require ` , there is an escape hatch
25
+ available: ` __original_require__ ` is the original value of ` require ` without
26
+ our wrapping applied.
33
27
34
28
Since the ` script ` is just a function body, these values will already be
35
29
defined, so you don't have to (see examples below).
@@ -255,7 +249,7 @@ jobs:
255
249
- uses : actions/github-script@v3
256
250
with :
257
251
script : |
258
- const script = require(` ./path/to/script.js` )
252
+ const script = require(' ./path/to/script.js' )
259
253
console.log(script({github, context}))
260
254
` ` `
261
255
@@ -295,7 +289,7 @@ jobs:
295
289
SHA : ' ${{env.parentSHA}}'
296
290
with :
297
291
script : |
298
- const script = require(` ./path/to/script.js` )
292
+ const script = require(' ./path/to/script.js' )
299
293
await script({github, context, core})
300
294
` ` `
301
295
@@ -334,18 +328,13 @@ jobs:
334
328
- uses : actions/github-script@v3
335
329
with :
336
330
script : |
337
- const execa = require(`./node_modules/ execa` )
331
+ const execa = require(' execa' )
338
332
339
333
const { stdout } = await execa('echo', ['hello', 'world'])
340
334
341
335
console.log(stdout)
342
336
` ` `
343
337
344
- _(Note that at this time, one still has to specify ` node_modules` in the
345
- require path for modules in the working directory of the step that is
346
- running. Hopefully we will have a solution for this in the future, but not
347
- quite, yet.)_
348
-
349
338
### Use env as input
350
339
351
340
You can set env vars to use them in your script:
0 commit comments