Skip to content

Commit

Permalink
docs: use GITHUB_WORKSPACE environment variable
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
Ahmad Nassri authored and GitHub committed Jul 29, 2020
1 parent 83107c8 commit a656f43
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)*

And then export a function from your module:

```javascript
module.exports = ({context}) => {
module.exports = (github, context) => {
return context.payload.client_payload.value
}
```
Expand Down

0 comments on commit a656f43

Please sign in to comment.