Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3f92623

Browse files
authored
Merge pull request actions#74 from ahmadnassri/patch-1
docs: use GITHUB_WORKSPACE environment variable
2 parents 83107c8 + 07ecbc5 commit 3f92623

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

README.md

Lines changed: 4 additions & 5 deletions
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#default-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)