@@ -71,14 +71,14 @@ in case you need to use a non-default token.
71
71
72
72
By default, github-script will use the token provided to your workflow.
73
73
74
- # ## Print the available attributes of context:
74
+ # ## Print the available attributes of context
75
75
76
76
` ` ` yaml
77
77
- name: View context attributes
78
78
uses: actions/github-script@v3
79
79
with:
80
80
script: console.log(context)
81
- ` ` `
81
+ ` ` `
82
82
83
83
# ## Comment on an issue
84
84
@@ -200,7 +200,6 @@ contain the actual diff text.
200
200
You can use the `github.graphql` object to run custom GraphQL queries against the GitHub API.
201
201
202
202
` ` ` yaml
203
-
204
203
jobs:
205
204
list-issues:
206
205
runs-on: ubuntu-latest
@@ -225,7 +224,6 @@ jobs:
225
224
}
226
225
const result = await github.graphql(query, variables)
227
226
console.log(result)
228
-
229
227
```
230
228
231
229
### Run a separate file
@@ -268,3 +266,31 @@ external function.
268
266
Additionally, you'll want to use the [checkout
269
267
action](https://github.com/actions/checkout) to make sure your script file is
270
268
available.
269
+
270
+ # ## Use npm packages
271
+
272
+ Like importing your own files above, you can also use installed modules :
273
+
274
+ ` ` ` yaml
275
+ on: push
276
+
277
+ jobs:
278
+ echo-input:
279
+ runs-on: ubuntu-latest
280
+ steps:
281
+ - uses: actions/checkout@v2
282
+ - uses: actions/setup-node@v2
283
+ with:
284
+ node-version: 14
285
+ - run: npm ci
286
+ # or one-off:
287
+ - run: npm install -g execa
288
+ - uses: actions/github-script@v3
289
+ with:
290
+ script: |
291
+ const execa = require(` ${process.env.GITHUB_WORKSPACE}/node_modules/execa`)
292
+
293
+ const { stdout } = await execa('echo', ['hello', 'world'])
294
+
295
+ console.log(stdout)
296
+ ```
0 commit comments