feat: add-paths input (#1010)

* add add-pattern-array argument

* ignore return code

* doc to add-pattern-array

* update README.md

* cleanup after success commit

* fix integration tests

* add test

* update naming and docs

* update readme

* fix missing await

* update docs

Co-authored-by: avdim <avdim@mail.ru>
Co-authored-by: Авдеев Дима <avdeev@tutu.tech>
This commit is contained in:
Peter Evans 2021-12-14 11:23:29 +09:00 committed by GitHub
parent 4b53b6fd1a
commit dcd5fd746d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 229 additions and 65 deletions

View file

@ -91,7 +91,8 @@ export async function createOrUpdateBranch(
base: string,
branch: string,
branchRemoteName: string,
signoff: boolean
signoff: boolean,
addPaths: string[]
): Promise<CreateOrUpdateBranchResult> {
// Get the working base.
// When a ref, it may or may not be the actual base.
@ -120,12 +121,17 @@ export async function createOrUpdateBranch(
// Commit any uncommitted changes
if (await git.isDirty(true)) {
core.info('Uncommitted changes found. Adding a commit.')
await git.exec(['add', '-A'])
for (const path of addPaths) {
await git.exec(['add', path], true)
}
const params = ['-m', commitMessage]
if (signoff) {
params.push('--signoff')
}
await git.commit(params)
// Remove uncommitted tracked and untracked changes
await git.exec(['reset', '--hard'])
await git.exec(['clean', '-f'])
}
// Perform fetch and reset the working base

View file

@ -12,6 +12,7 @@ import * as utils from './utils'
export interface Inputs {
token: string
path: string
addPaths: string[]
commitMessage: string
committer: string
author: string
@ -173,7 +174,8 @@ export async function createPullRequest(inputs: Inputs): Promise<void> {
inputs.base,
inputs.branch,
branchRemoteName,
inputs.signoff
inputs.signoff,
inputs.addPaths
)
core.endGroup()

View file

@ -8,6 +8,7 @@ async function run(): Promise<void> {
const inputs: Inputs = {
token: core.getInput('token'),
path: core.getInput('path'),
addPaths: utils.getInputAsArray('add-paths'),
commitMessage: core.getInput('commit-message'),
committer: core.getInput('committer'),
author: core.getInput('author'),