create-github-app-token/tests/main-missing-private-key.test.js
Parker Brown f24bbd8964
fix: validate private-key input (#376)
## Summary

When `private-key` resolves to an empty value, the action currently lets
Octokit fail with `[@octokit/auth-app] privateKey option is required`,
which points at an implementation detail instead of the action input.
This adds action-level validation so users get the same non-empty input
guidance used for missing `client-id` or `app-id`.

- Validate `private-key` before creating app auth
- Add a regression test and snapshot for the missing private key path
- Leave valid private key handling unchanged, including escaped newlines

Co-authored-by: Copilot <[email protected]>
2026-05-12 16:05:46 -07:00

19 lines
600 B
JavaScript

import { DEFAULT_ENV } from "./main.js";
for (const [key, value] of Object.entries({
...DEFAULT_ENV,
"INPUT_PRIVATE-KEY": "",
})) {
process.env[key] = value;
}
// Log only the error message, not the full stack trace, because the stack
// trace contains environment-specific paths and ANSI codes that differ
// between local and CI environments.
const _error = console.error;
console.error = (err) => _error(err?.message ?? err);
// Verify `main` exits with an error when `private-key` is not set.
const { default: promise } = await import("../main.js");
await promise;
process.exitCode = 0;