-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The bash entrypoint was causing issues trying to resolve paths, so this approach attempts to prevent that from being an issue across platforms.
- Loading branch information
Showing
4 changed files
with
39 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
20.6.0 | ||
21.6.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,38 @@ | ||
#!/usr/bin/env bash | ||
#!/usr/bin/env node | ||
const path = require('path') | ||
const { execSync } = require('child_process') | ||
|
||
# This script is used to run the local action. It sets the NODE_OPTIONS | ||
# environment variable to require the bootstrap file, which sets up the | ||
# TypeScript environment for the action. | ||
/** | ||
* This script is used to run the local action. It sets the NODE_OPTIONS | ||
* environment variable to require the bootstrap file, which sets up the | ||
* TypeScript environment for the action. | ||
*/ | ||
|
||
# Set the first argument (local path to action) as an env var. This is used | ||
# in the bootstrap file to check for a `tsconfig.json`. | ||
export TARGET_ACTION_PATH="$1" | ||
// Set the first argument (path to action directory) as an environment variable. | ||
// This is used in the bootstrap file to check for a `tsconfig.json`. | ||
const actionPath = process.argv[2] ? path.resolve(process.argv[2]) : '' | ||
process.env.TARGET_ACTION_PATH = actionPath | ||
|
||
# Set the NODE_OPTIONS environment variable to require the bootstrap file | ||
NODE_OPTIONS='--require "./src/bootstrap.js"' npx tsx "./src/index.ts" "$@" | ||
// Get the other arguments, if present. Validation and error handling is done | ||
// within the package itself. | ||
const entrypoint = process.argv[3] ?? '' | ||
const dotenvFile = process.argv[4] ? path.resolve(process.argv[4]) : '' | ||
|
||
// Get the absolute path to the `@github/local-action` package. | ||
const packagePath = path.resolve(__dirname, '..') | ||
const packageIndex = path.join(packagePath, 'src', 'index.ts') | ||
|
||
// Set the NODE_OPTIONS environment variable to require the bootstrap file | ||
const options = `--require "${path.join(packagePath, 'src', 'bootstrap.js')}"` | ||
process.env.NODE_OPTIONS = process.env.NODE_OPTIONS | ||
? `${process.env.NODE_OPTIONS} ${options}` | ||
: options | ||
|
||
// Run the action | ||
const command = `npx tsx "${packageIndex}" "${actionPath}" "${entrypoint}" "${dotenvFile}"` | ||
|
||
try { | ||
execSync(command, { cwd: packagePath, stdio: 'inherit' }) | ||
} catch (error) { | ||
process.exit(error.status) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name": "@github/local-action", | ||
"description": "Local Debugging for GitHub Actions", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"author": "Nick Alteen <[email protected]>", | ||
"private": false, | ||
"homepage": "https://github.com/github/local-action", | ||
|