Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit9ac0880

Browse files
authored
Merge pull requestactions#240 from actions/joshmgross/document-esm
Add an example using ESM `import`
2 parents53cdbb4 +5541733 commit9ac0880

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

‎README.md

Lines 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)

[8]ページ先頭

©2009-2025 Movatter.jp