Skip to content

docs: use GITHUB_WORKSPACE environment variable #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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#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
}
```
Expand Down