Merge pull request #74 from ahmadnassri/patch-1

docs: use GITHUB_WORKSPACE environment variable
This commit is contained in:
Jonathan Clem
2020-07-29 11:49:55 -04:00
committed by GitHub

View File

@@ -198,17 +198,16 @@ jobs:
- uses: actions/github-script@v2
with:
script: |
const path = require('path')
const scriptPath = path.resolve('./path/to/script.js')
console.log(require(scriptPath)({context}))
const script = require(`${process.env.GITHUB_WORKSPACE}/path/to/script.js`)
console.log(script({github, context}))
```
*Note that the script path given to `require()` must be an absolute path in this case, hence the call to `path.resolve()`.*
*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).*
And then export a function from your module:
```javascript
module.exports = ({context}) => {
module.exports = (github, context) => {
return context.payload.client_payload.value
}
```