mirror of
https://github.com/actions/github-script.git
synced 2026-06-06 09:04:23 +00:00
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
This commit is contained in:
parent
3a2844b7e9
commit
5ac99427a6
3 changed files with 14 additions and 0 deletions
|
|
@ -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`
|
||||
|
|
|
|||
5
dist/index.js
vendored
5
dist/index.js
vendored
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -59,6 +59,12 @@ async function main(): Promise<void> {
|
|||
|
||||
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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue