Skip to content

Commit a656f43

Browse files
author
Ahmad Nassri
authored
docs: use GITHUB_WORKSPACE environment variable
- update example for using `GITHUB_WORKSPACE` environment variable to keep things simple, and use less steps - include `github` object as a parameter to the sample script to better illustrate usage
1 parent 83107c8 commit a656f43

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

README.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -198,17 +198,16 @@ jobs:
198198
- uses: actions/github-script@v2
199199
with:
200200
script: |
201-
const path = require('path')
202-
const scriptPath = path.resolve('./path/to/script.js')
203-
console.log(require(scriptPath)({context}))
201+
const script = require(`${process.env.GITHUB_WORKSPACE}/.path/to/script.js`)
202+
console.log(script(github, context))
204203
```
205204

206-
*Note that the script path given to `require()` must be an absolute path in this case, hence the call to `path.resolve()`.*
205+
*Note that the script path given to `require()` must be an **absolute path** in this case, hence using [`GITHUB_WORKSPACE`](https://docs.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables)*
207206

208207
And then export a function from your module:
209208

210209
```javascript
211-
module.exports = ({context}) => {
210+
module.exports = (github, context) => {
212211
return context.payload.client_payload.value
213212
}
214213
```

0 commit comments

Comments
 (0)