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 5541733

Browse filesBrowse files
committed
Add an example using ESM import
1 parent 41e1ab4 commit 5541733
Copy full SHA for 5541733

File tree

Expand file treeCollapse file tree

1 file changed

+25
-0
lines changed
Filter options
Expand file treeCollapse file tree

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
@@ -338,6 +338,31 @@ jobs:
338338
console.log(stdout)
339339
```
340340
341+
### Use ESM `import`
342+
343+
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.
344+
345+
For a script in your repository `src/print-stuff.js`:
346+
```js
347+
export default function printStuff() { console.log('stuff') }
348+
```
349+
350+
```yaml
351+
on: push
352+
353+
jobs:
354+
print-stuff:
355+
runs-on: ubuntu-latest
356+
steps:
357+
- uses: actions/checkout@v2
358+
- uses: actions/github-script@v6
359+
with:
360+
script: |
361+
const { default: printStuff } = await import('${{ github.workspace }}/src/print-stuff.js')
362+
363+
await printStuff()
364+
```
365+
341366
### Use env as input
342367

343368
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.