Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a656f43

Browse filesBrowse 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
Copy full SHA for a656f43

File tree

1 file changed

+4
-5
lines changed
Filter options

1 file changed

+4
-5
lines changed

‎README.md

Copy file name to clipboardExpand all lines: README.md
+4-5Lines 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)*
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.