Commit graph

27 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
86e48e20ac
merge: incorporate main branch changes
- Resolve integration.yml merge conflicts (user-agent assertions)
- Fix OctokitOptions import path to @octokit/core/dist-types/types
- Rebuild dist
2026-04-09 22:10:00 +01:00
Salman Muin Kayser Chishti
ff8117e5b7 ci: fix user-agent test to handle orchestration ID 2026-04-09 19:24:48 +00:00
Salman Muin Kayser Chishti
81c6b78760 ci: use deployment: false to suppress deployment noise from integration tests 2026-04-09 19:02:40 +00:00
Salman Muin Kayser Chishti
c17d55b90d
ci: add getOctokit integration test job 2026-04-09 19:16:00 +01:00
copilot-swe-agent[bot]
c0078b2072 Simplify user-agent logic and update integration test
Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com>
2026-01-06 23:05:20 +00:00
Josh Gross
19e58d8525
Define permissions in workflows and update actions 2025-01-28 16:50:07 -05:00
Josh Gross
2f5a0ceb1a
Update integration test for expected package name 2025-01-17 14:44:04 -05:00
Josh Gross
d319f8f5b5
Avoid setting baseUrl to undefined when input is not provided 2023-11-17 11:59:30 -05:00
Josh Gross
384d6cf581
Fix quotations in tests 2023-11-08 10:07:35 -05:00
Josh Gross
84724927e3
Only validate GraphQL previews 2023-11-08 10:03:49 -05:00
Josh Gross
a903cf2d66
Add install deps action to reuse between workflows 2023-10-12 13:11:41 -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
Martijn Pieters
8d9f8fc050
Fix null handling, covered by integration tests
`core.getInput()` always returns a string, so testing for 'not null'
is always true. This then leads to previews set to an array with
a single empty string, breaking accept-header output.

Updated eslint rules should help avoid this issue in future, and new
integration tests verify that the github client configuration now
reflects the intended configuration options.
2023-04-04 22:11:47 +01:00
Martijn Pieters
806be26275
Clean and spruce up the integration tests a bit
- Use test-specific step ids
- Remove unused input parameters
- Provide clear output on what passed or failed, including
  a step summary for each passed test.
2023-04-04 21:18:14 +01:00
Austin Vazquez
20fcf2e7fe Update GitHub actions packages
Update actions/checkout, actions/setup-node, actions/cache, and
actions/upload-artifact from v2 to v3.

Signed-off-by: Austin Vazquez <macedonv@amazon.com>
2022-10-25 21:48:09 +00:00
Josh Gross
936c9d9f72
Update to latest actions 2021-06-28 14:45:32 -04:00
Jonathan Clem
5ee517dae8
Workflow syntax error 2021-04-21 17:43:39 -04:00
Jonathan Clem
fb7e8f7c67
Add npm ci to integration test 2021-04-21 17:43:02 -04:00
Jonathan Clem
4a93ad9f9e
Add actions/checkout 2021-04-21 17:41:41 -04:00
Jonathan Clem
19e7914023
Add integration test running 2021-04-21 17:39:54 -04:00
Jonathan Clem
3ede58996d
Add new integration tests 2021-04-21 17:37:37 -04:00
Jonathan Clem
cf1dcb0bd5
Add nicer status badges and workflow names 2020-08-21 11:13:16 -04:00
Jonathan Clem
1ba1e95cf2
Replace default branch name with main 2020-07-14 16:36:10 -04:00
Jonathan Clem
dc16f26602
Add core to integration test 2020-03-24 14:02:45 -04:00
Jonathan Clem
ec171b8961
Use master 2020-02-27 17:53:27 -05:00
Jonathan Clem
d73e75dea8
Separate integration workflow 2020-02-27 17:52:43 -05:00