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

12
dist/index.js vendored
View file

@ -98,7 +98,7 @@ function splitLines(multilineString) {
.map(s => s.trim())
.filter(x => x !== '');
}
function createOrUpdateBranch(git, commitMessage, base, branch, branchRemoteName, signoff) {
function createOrUpdateBranch(git, commitMessage, base, branch, branchRemoteName, signoff, addPaths) {
return __awaiter(this, void 0, void 0, function* () {
// Get the working base.
// When a ref, it may or may not be the actual base.
@ -124,12 +124,17 @@ function createOrUpdateBranch(git, commitMessage, base, branch, branchRemoteName
// Commit any uncommitted changes
if (yield git.isDirty(true)) {
core.info('Uncommitted changes found. Adding a commit.');
yield git.exec(['add', '-A']);
for (const path of addPaths) {
yield git.exec(['add', path], true);
}
const params = ['-m', commitMessage];
if (signoff) {
params.push('--signoff');
}
yield git.commit(params);
// Remove uncommitted tracked and untracked changes
yield git.exec(['reset', '--hard']);
yield git.exec(['clean', '-f']);
}
// Perform fetch and reset the working base
// Commits made during the workflow will be removed
@ -377,7 +382,7 @@ function createPullRequest(inputs) {
core.endGroup();
// Create or update the pull request branch
core.startGroup('Create or update the pull request branch');
const result = yield (0, create_or_update_branch_1.createOrUpdateBranch)(git, inputs.commitMessage, inputs.base, inputs.branch, branchRemoteName, inputs.signoff);
const result = yield (0, create_or_update_branch_1.createOrUpdateBranch)(git, inputs.commitMessage, inputs.base, inputs.branch, branchRemoteName, inputs.signoff, inputs.addPaths);
core.endGroup();
if (['created', 'updated'].includes(result.action)) {
// The branch was created or updated
@ -1074,6 +1079,7 @@ function run() {
const 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'),