Commit graph

28 commits

Author SHA1 Message Date
Osher
67c280d263 feat: add script-file input for lint-friendly external JS scripts
Closes #714

Inline `script` is a YAML string — invisible to linters and IDEs.
The common workaround was wrapping a `require` call inside the inline script,
which still needs boilerplate and assumes a path convention.

New optional `script-file` input that accepts a path to a JS file.
The file must `module.exports` an async function receiving the standard
IoC dependency bag (`github`, `octokit`, `getOctokit`, `context`, `core`,
`exec`, `glob`, `io`, `require`).

```yaml
- uses: actions/checkout@v4
- uses: actions/github-script@v9
  with:
    script-file: .github/scripts/my-script.js
```

`script` and `script-file` are mutually exclusive — exactly one must be provided.
Relative paths resolve against `$GITHUB_WORKSPACE`; absolute paths are used as-is.

- `action.yml` — adds `script-file` input; makes `script` optional
- `src/script-file.ts` — path resolution and script loading logic
- `src/args.ts` — `AsyncFunctionArguments` extracted from `async-function.ts` so neither execution path depends on the other
- `src/main.ts` — mutual-exclusion validation; dispatches to the right execution path
- `types/non-webpack-require.ts` — corrects `__non_webpack_require__` type from deprecated `NodeRequire` / wrong `NodeJS.RequireResolve` to `NodeJS.Require`
- `__test__/script-file.test.ts` — 10 tests covering path resolution, arg forwarding, error cases
- `README.md` — new `## Script file` section with usage, IoC bag table, path resolution rules
- `.github/fixtures/script-file/` — fixture JS files for integration tests
- `.github/workflows/integration.yml` — 10 new integration test jobs: happy path (relative path, absolute path, all IoC args, json/string encoding,
  require-in-file) and error cases (both inputs set, neither set, nonexistent file, non-function export, file:// protocol)
2026-04-26 12:06:28 +03:00
Salman Muin Kayser Chishti
2c81ba05f3 Update Node.js version support to 24.x
Bump Node.js version requirement from 20.x to 24.x in action configuration and package files. Update @types/node and undici-types dependencies to match Node 24 compatibility.
2025-07-29 14:08:35 +01:00
Josh Gross
84724927e3
Only validate GraphQL previews 2023-11-08 10:03:49 -05:00
Josh Gross
5349cf9965
Merge branch 'main' into joshmgross/node-20 2023-11-08 09:45:02 -05:00
Rob Anderson
5940a76378
add example to description of base-url parameter 2023-10-23 17:37:49 -06:00
Rob Anderson
ef8023aa4a
Update action.yml
Co-authored-by: Josh Gross <joshmgross@github.com>
2023-10-23 19:35:20 -04:00
Rob Anderson
ea121b86f9
add base-url option 2023-10-20 10:16:28 -06:00
Josh Gross
84ab08fe8b
Update dependencies and use Node 20 2023-10-11 16:11:59 -04:00
Martijn Pieters
ea954ff83a
Default debug to current runner debug state
When the action 'debug' input is not set, default to the current
runner debug state. This ensures that the Octokit client request logs
are included automatically when you re-run a job with debug enabled.
2023-04-05 17:26:25 +01:00
Luke Tomlinson
6b09a22cca cleanup quotes 2022-09-23 16:28:30 -04:00
Luke Tomlinson
e7dbaf0565 update action.yml 2022-09-23 16:25:00 -04:00
Luke Tomlinson
3faaff918c PR feedback 2022-09-23 16:16:31 -04:00
Luke Tomlinson
977060a05e Add more info to action.yml 2022-09-23 11:56:48 -04:00
Luke Tomlinson
355d8955d8 Add retry plugin 2022-09-23 10:56:21 -04:00
Thomas Boop
d2ed94b14f
Update default runtime to node16
Node 12 has an end of life on April 30, 2022.

This PR updates the default runtime to [node16](https://github.blog/changelog/2021-12-10-github-actions-github-hosted-runners-now-run-node-js-16-by-default/), rather then node12. 

This is supported on all Actions Runners v2.285.0 or later.
2022-02-07 14:00:27 -05:00
Josh Gross
1d4576cfc1 Default to the GitHub token 2020-01-22 22:26:04 -05:00
Jonathan Clem
622ce3121a
Accept json or string encoding of result 2020-01-08 14:39:09 -05:00
francisfuzz
93e067c319 feature: build source file with ncc 2020-01-03 09:19:52 -08:00
Jonathan Clem
9f3a1f1343
Add GitHub as author 2019-11-13 15:04:08 -08:00
Edward Thomson
4f0c94ef13 Update description 2019-11-08 16:22:35 +00:00
Jonathan Clem
fbe453a850
Transform inputs from strings 2019-09-05 11:39:22 -04:00
Jonathan Clem
e6944039f8
Remove empty list from action.yml 2019-09-05 11:34:38 -04:00
Jonathan Clem
e3df9c68fb
Add debug, user-agent, and previews inputs 2019-09-05 09:35:47 -04:00
Jonathan Clem
a113ccad71
Use code icon 2019-09-05 09:20:46 -04:00
Jonathan Clem
75fbffad34
Rename to github-script 2019-09-05 09:20:37 -04:00
Jonathan Clem
436154793f
Add newline to end of action.yml 2019-08-29 18:52:32 -04:00
Jonathan Clem
d6f96b0015
Add branding to action.yml 2019-08-29 18:52:12 -04:00
Jonathan Clem
8080ea76f3
Initial pass on script Action 2019-08-29 18:46:42 -04:00