Add support for committing with no-verify

This commit is contained in:
Becky Fulton 2023-04-18 12:12:29 +01:00
parent 2827897dcc
commit a9029b0f6a
5 changed files with 15 additions and 3 deletions

View file

@ -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:

View file

@ -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'

View file

@ -120,7 +120,8 @@ export async function createOrUpdateBranch(
branch: string,
branchRemoteName: string,
signoff: boolean,
addPaths: string[]
addPaths: string[],
noVerify: boolean
): Promise<CreateOrUpdateBranchResult> {
// 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 (

View file

@ -31,6 +31,7 @@ export interface Inputs {
teamReviewers: string[]
milestone: number
draft: boolean
noVerify: boolean
}
export async function createPullRequest(inputs: Inputs): Promise<void> {
@ -192,7 +193,8 @@ export async function createPullRequest(inputs: Inputs): Promise<void> {
inputs.branch,
branchRemoteName,
inputs.signoff,
inputs.addPaths
inputs.addPaths,
inputs.noVerify
)
core.endGroup()

View file

@ -26,7 +26,8 @@ async function run(): Promise<void> {
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)}`)