diff --git a/README.md b/README.md index e6f399d..6b885f7 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![Become a sponsor](https://img.shields.io/badge/sponsor-crazy--max-181717.svg?logo=github&style=flat-square)](https://github.com/sponsors/crazy-max) [![Paypal Donate](https://img.shields.io/badge/donate-paypal-00457c.svg?logo=paypal&style=flat-square)](https://www.paypal.me/crazyws) -## About +## About GitHub Action to easily import a GPG key. @@ -22,6 +22,7 @@ ___ * [Sign commits](#sign-commits) * [Customizing](#customizing) * [inputs](#inputs) + * [outputs](#outputs) * [environment variables](#environment-variables) * [Keep up-to-date with GitHub Dependabot](#keep-up-to-date-with-github-dependabot) * [How can I help?](#how-can-i-help) @@ -137,6 +138,7 @@ Following inputs can be used as `step.with` keys | `git_push_gpgsign`**¹** | Bool | Sign all pushes automatically. (default `false`) | | `git_committer_name`**¹** | String | Set commit author's name (defaults to the name associated with the GPG key) | | `git_committer_email`**¹** | String | Set commit author's email (defaults to the email address associated with the GPG key) | +| `workdir` | String | Working directory (below repository root) | > **¹** `git_user_signingkey` needs to be enabled for these inputs to be used. diff --git a/action.yml b/action.yml index 9b58f3d..127da43 100644 --- a/action.yml +++ b/action.yml @@ -29,6 +29,10 @@ inputs: git_committer_email: description: 'Commit author''s email' required: false + workdir: + description: 'Working directory (below repository root)' + default: '.' + required: false outputs: fingerprint: diff --git a/dist/index.js b/dist/index.js index cf8f319..e70d7ad 100644 --- a/dist/index.js +++ b/dist/index.js @@ -295,6 +295,11 @@ function run() { const git_push_gpgsign = /true/i.test(core.getInput('git_push_gpgsign')); const git_committer_name = core.getInput('git_committer_name'); const git_committer_email = core.getInput('git_committer_email'); + const workdir = core.getInput('workdir') || '.'; + if (workdir && workdir !== '.') { + core.info(`📂 Using ${workdir} as working directory...`); + process.chdir(workdir); + } core.info('📣 GnuPG info'); const version = yield gpg.getVersion(); const dirs = yield gpg.getDirs(); diff --git a/src/main.ts b/src/main.ts index 222f5c7..b6b9447 100644 --- a/src/main.ts +++ b/src/main.ts @@ -17,6 +17,12 @@ async function run(): Promise { const git_push_gpgsign = /true/i.test(core.getInput('git_push_gpgsign')); const git_committer_name: string = core.getInput('git_committer_name'); const git_committer_email: string = core.getInput('git_committer_email'); + const workdir: string = core.getInput('workdir') || '.'; + + if (workdir && workdir !== '.') { + core.info(`📂 Using ${workdir} as working directory...`); + process.chdir(workdir); + } core.info('📣 GnuPG info'); const version = await gpg.getVersion();