From a9029b0f6abc08bec8413ae7d8f1ef66df690193 Mon Sep 17 00:00:00 2001 From: Becky Fulton <102167563+becky-sequence@users.noreply.github.com> Date: Tue, 18 Apr 2023 12:12:29 +0100 Subject: [PATCH] Add support for committing with no-verify --- README.md | 2 ++ action.yml | 3 +++ src/create-or-update-branch.ts | 6 +++++- src/create-pull-request.ts | 4 +++- src/main.ts | 3 ++- 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8a341e2..76d742e 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,7 @@ All inputs are **optional**. If not set, sensible defaults will be used. | `team-reviewers` | A comma or newline-separated list of GitHub teams to request a review from. Note that a `repo` scoped [PAT](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token), or equivalent [GitHub App permissions](docs/concepts-guidelines.md#authenticating-with-github-app-generated-tokens), are required. | | | `milestone` | The number of the milestone to associate this pull request with. | | | `draft` | Create a [draft pull request](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests#draft-pull-requests). It is not possible to change draft status after creation except through the web interface. | `false` | +| `skip-hooks` | Skip hooks when committing changes. | `false` | For self-hosted runners behind a corporate proxy set the `https_proxy` environment variable. ```yml @@ -257,6 +258,7 @@ jobs: qa-team milestone: 1 draft: false + skip-hooks: false ``` An example based on the above reference configuration creates pull requests that look like this: diff --git a/action.yml b/action.yml index d264e38..99f82f1 100644 --- a/action.yml +++ b/action.yml @@ -71,6 +71,9 @@ inputs: draft: description: 'Create a draft pull request. It is not possible to change draft status after creation except through the web interface' default: false + skip-hooks: + description: 'Skip hooks when committing changes' + default: false outputs: pull-request-number: description: 'The pull request number' diff --git a/src/create-or-update-branch.ts b/src/create-or-update-branch.ts index cb1fcbb..75012b2 100644 --- a/src/create-or-update-branch.ts +++ b/src/create-or-update-branch.ts @@ -120,7 +120,8 @@ export async function createOrUpdateBranch( branch: string, branchRemoteName: string, signoff: boolean, - addPaths: string[] + addPaths: string[], + noVerify: boolean ): Promise { // Get the working base. // When a ref, it may or may not be the actual base. @@ -160,6 +161,9 @@ export async function createOrUpdateBranch( if (signoff) { popts.push('--signoff') } + if (noVerify) { + popts.push('--no-verify') + } const commitResult = await git.commit(popts, true) // 'nothing to commit' can occur when core.autocrlf is set to true if ( diff --git a/src/create-pull-request.ts b/src/create-pull-request.ts index 309bb67..8113bd6 100644 --- a/src/create-pull-request.ts +++ b/src/create-pull-request.ts @@ -31,6 +31,7 @@ export interface Inputs { teamReviewers: string[] milestone: number draft: boolean + noVerify: boolean } export async function createPullRequest(inputs: Inputs): Promise { @@ -192,7 +193,8 @@ export async function createPullRequest(inputs: Inputs): Promise { inputs.branch, branchRemoteName, inputs.signoff, - inputs.addPaths + inputs.addPaths, + inputs.noVerify ) core.endGroup() diff --git a/src/main.ts b/src/main.ts index 711d0c3..a85a6d1 100644 --- a/src/main.ts +++ b/src/main.ts @@ -26,7 +26,8 @@ async function run(): Promise { reviewers: utils.getInputAsArray('reviewers'), teamReviewers: utils.getInputAsArray('team-reviewers'), milestone: Number(core.getInput('milestone')), - draft: core.getBooleanInput('draft') + draft: core.getBooleanInput('draft'), + noVerify: core.getBooleanInput('skip-hooks') } core.debug(`Inputs: ${inspect(inputs)}`)