From 5ac99427a6ccafcc8d8a75dc696a00d1a7109042 Mon Sep 17 00:00:00 2001 From: mehmet turac Date: Mon, 11 May 2026 10:16:51 +0300 Subject: [PATCH] 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 --- action.yml | 3 +++ dist/index.js | 5 +++++ src/main.ts | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/action.yml b/action.yml index 6640208..eabd760 100644 --- a/action.yml +++ b/action.yml @@ -32,6 +32,9 @@ inputs: base-url: description: An optional GitHub REST API URL to connect to a different GitHub instance. For example, https://my.github-enterprise-server.com/api/v3 required: false + working-directory: + description: The working directory where the script will be executed. If not provided, the current working directory is used. + required: false outputs: result: description: The return value of the script, stringified with `JSON.stringify` diff --git a/dist/index.js b/dist/index.js index 1a6aae4..8dd5bbc 100644 --- a/dist/index.js +++ b/dist/index.js @@ -65092,6 +65092,11 @@ async function main() { } const github = getOctokit(token, opts, retry, requestLog); const script = core.getInput('script', { required: true }); + const workingDirectory = core.getInput('working-directory'); + if (workingDirectory) { + core.info(`Changing working directory to ${workingDirectory}`); + process.chdir(workingDirectory); + } // Wrap getOctokit so secondary clients inherit retry, logging, // orchestration ID, and the action's retries input. // Deep-copy opts to prevent shared references with the primary client. diff --git a/src/main.ts b/src/main.ts index 45677ff..ffc7c8b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -59,6 +59,12 @@ async function main(): Promise { const github = getOctokit(token, opts, retry, requestLog) const script = core.getInput('script', {required: true}) + const workingDirectory = core.getInput('working-directory') + + if (workingDirectory) { + core.info(`Changing working directory to ${workingDirectory}`) + process.chdir(workingDirectory) + } // Wrap getOctokit so secondary clients inherit retry, logging, // orchestration ID, and the action's retries input.