Skip to content

Commit 5ac9942

Browse files
committed
feat: add working-directory input to change script execution directory
- Add working-directory input to action.yml - Implement process.chdir() in main.ts before script execution - Users can now specify working directory without modifying scripts Closes #426
1 parent 3a2844b commit 5ac9942

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ inputs:
3232
base-url:
3333
description: An optional GitHub REST API URL to connect to a different GitHub instance. For example, https://my.github-enterprise-server.com/api/v3
3434
required: false
35+
working-directory:
36+
description: The working directory where the script will be executed. If not provided, the current working directory is used.
37+
required: false
3538
outputs:
3639
result:
3740
description: The return value of the script, stringified with `JSON.stringify`

dist/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65092,6 +65092,11 @@ async function main() {
6509265092
}
6509365093
const github = getOctokit(token, opts, retry, requestLog);
6509465094
const script = core.getInput('script', { required: true });
65095+
const workingDirectory = core.getInput('working-directory');
65096+
if (workingDirectory) {
65097+
core.info(`Changing working directory to ${workingDirectory}`);
65098+
process.chdir(workingDirectory);
65099+
}
6509565100
// Wrap getOctokit so secondary clients inherit retry, logging,
6509665101
// orchestration ID, and the action's retries input.
6509765102
// Deep-copy opts to prevent shared references with the primary client.

src/main.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ async function main(): Promise<void> {
5959

6060
const github = getOctokit(token, opts, retry, requestLog)
6161
const script = core.getInput('script', {required: true})
62+
const workingDirectory = core.getInput('working-directory')
63+
64+
if (workingDirectory) {
65+
core.info(`Changing working directory to ${workingDirectory}`)
66+
process.chdir(workingDirectory)
67+
}
6268

6369
// Wrap getOctokit so secondary clients inherit retry, logging,
6470
// orchestration ID, and the action's retries input.

0 commit comments

Comments
 (0)