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 9ac0880

Browse filesBrowse files
authored
Merge pull request actions#240 from actions/joshmgross/document-esm
Add an example using ESM `import`
2 parents 53cdbb4 + 5541733 commit 9ac0880
Copy full SHA for 9ac0880

File tree

1 file changed

+25
-0
lines changed
Filter options

1 file changed

+25
-0
lines changed

‎README.md

Copy file name to clipboardExpand all lines: README.md
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,31 @@ jobs:
346346
console.log(stdout)
347347
```
348348
349+
### Use ESM `import`
350+
351+
To import an ESM file, you'll need to reference your script by an absolute path and ensure you have a `package.json` file with `"type": "module"` specified.
352+
353+
For a script in your repository `src/print-stuff.js`:
354+
```js
355+
export default function printStuff() { console.log('stuff') }
356+
```
357+
358+
```yaml
359+
on: push
360+
361+
jobs:
362+
print-stuff:
363+
runs-on: ubuntu-latest
364+
steps:
365+
- uses: actions/checkout@v2
366+
- uses: actions/github-script@v6
367+
with:
368+
script: |
369+
const { default: printStuff } = await import('${{ github.workspace }}/src/print-stuff.js')
370+
371+
await printStuff()
372+
```
373+
349374
### Use env as input
350375

351376
You can set env vars to use them in your script:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.