mirror of
https://github.com/actions/github-script.git
synced 2026-04-08 07:00:05 +00:00
Run script in GITHUB_WORKSPACE directory
Change to the GITHUB_WORKSPACE directory before running the script so that callers do not have to exlicitly use the GITHUB_WORKSPACE environment variable when requiring script files. Workflow run steps are run within the GITHUB_WORKSPACE so this seems like the expected default.
This commit is contained in:
parent
f05a81df23
commit
7dc493a321
4 changed files with 73 additions and 6 deletions
15
dist/index.js
vendored
15
dist/index.js
vendored
|
|
@ -6117,8 +6117,19 @@ var io = __webpack_require__(436);
|
|||
// CONCATENATED MODULE: ./src/async-function.ts
|
||||
const AsyncFunction = Object.getPrototypeOf(async () => null).constructor;
|
||||
function callAsyncFunction(args, source) {
|
||||
const fn = new AsyncFunction(...Object.keys(args), source);
|
||||
return fn(...Object.values(args));
|
||||
const previousWorkingDirectory = process.cwd();
|
||||
try {
|
||||
if (process.env.GITHUB_WORKSPACE !== undefined) {
|
||||
process.chdir(process.env.GITHUB_WORKSPACE);
|
||||
}
|
||||
const fn = new AsyncFunction(...Object.keys(args), source);
|
||||
return fn(...Object.values(args));
|
||||
}
|
||||
finally {
|
||||
if (previousWorkingDirectory !== process.cwd()) {
|
||||
process.chdir(previousWorkingDirectory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// CONCATENATED MODULE: ./src/main.ts
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue