From 6fa44e144d8537d5164788e703baee64f4a81255 Mon Sep 17 00:00:00 2001 From: Peter Evans Date: Sun, 19 Jul 2020 15:09:44 +0900 Subject: [PATCH] Set defaults in action.yml --- action.yml | 66 ++++++++++++++++++++++---------------- dist/index.js | 19 +++-------- src/create-pull-request.ts | 20 ++---------- src/main.ts | 8 ++--- 4 files changed, 50 insertions(+), 63 deletions(-) diff --git a/action.yml b/action.yml index 067db42..c1f3678 100644 --- a/action.yml +++ b/action.yml @@ -2,42 +2,54 @@ name: 'Create Pull Request' description: 'Creates a pull request for changes to your repository in the actions workspace' inputs: token: - description: 'GITHUB_TOKEN or a repo scoped PAT' + description: 'GITHUB_TOKEN or a `repo` scoped Personal Access Token (PAT)' default: ${{ github.token }} path: - description: 'Relative path under $GITHUB_WORKSPACE to the repository.' + description: > + Relative path under $GITHUB_WORKSPACE to the repository. + Defaults to $GITHUB_WORKSPACE. commit-message: description: 'The message to use when committing changes.' + default: '[create-pull-request] automated change' committer: - description: 'The committer name and email address.' + description: > + The committer name and email address in the format `Display Name `. + Defaults to the GitHub Actions bot user if an identity is not found in git config. author: - description: 'The author name and email address.' - title: - description: 'The title of the pull request.' - body: - description: 'The body of the pull request.' - labels: - description: 'A comma separated list of labels.' - assignees: - description: 'A comma separated list of assignees (GitHub usernames).' - reviewers: - description: 'A comma separated list of reviewers (GitHub usernames) to request a review from.' - team-reviewers: - description: 'A comma separated list of GitHub teams to request a review from.' - milestone: - description: 'The number of the milestone to associate this pull request with.' - project: - description: 'Deprecated. See README for details.' - project-column: - description: 'Deprecated. See README for details.' - draft: - description: 'Create a draft pull request' + description: > + The author name and email address in the format `Display Name `. + Defaults to the GitHub Actions bot user if an identity is not found in git config. branch: description: 'The pull request branch name.' - push-to-fork: - description: 'A fork of the checked out base repository to which the pull request branch will be pushed.' + default: 'create-pull-request/patch' base: - description: 'The pull request base branch.' + description: > + The pull request base branch. + Defaults to the branch checked out in the workflow. + push-to-fork: + description: > + A fork of the checked out parent repository to which the pull request branch will be pushed. + e.g. 'owner/repo-fork' + The pull request will be created to merge the fork's branch into the parent's base. + title: + description: 'The title of the pull request.' + default: 'Changes by create-pull-request action' + body: + description: 'The body of the pull request.' + default: 'Automated changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action' + labels: + description: 'A comma or newline separated list of labels.' + assignees: + description: 'A comma or newline separated list of assignees (GitHub usernames).' + reviewers: + description: 'A comma or newline separated list of reviewers (GitHub usernames) to request a review from.' + team-reviewers: + description: 'A comma or newline separated list of GitHub teams to request a review from.' + milestone: + description: 'The number of the milestone to associate the pull request with.' + draft: + description: 'Create a draft pull request' + default: false outputs: pull-request-number: description: 'The pull request number' diff --git a/dist/index.js b/dist/index.js index 388209e..3bd06f2 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1296,6 +1296,9 @@ function run() { commitMessage: core.getInput('commit-message'), committer: core.getInput('committer'), author: core.getInput('author'), + branch: core.getInput('branch'), + base: core.getInput('base'), + pushToFork: core.getInput('push-to-fork'), title: core.getInput('title'), body: core.getInput('body'), labels: utils.getInputAsArray('labels'), @@ -1303,10 +1306,7 @@ function run() { reviewers: utils.getInputAsArray('reviewers'), teamReviewers: utils.getInputAsArray('team-reviewers'), milestone: Number(core.getInput('milestone')), - draft: core.getInput('draft') === 'true', - branch: core.getInput('branch'), - pushToFork: core.getInput('push-to-fork'), - base: core.getInput('base') + draft: core.getInput('draft') === 'true' }; core.debug(`Inputs: ${util_1.inspect(inputs)}`); yield create_pull_request_1.createPullRequest(inputs); @@ -10592,10 +10592,6 @@ const git_command_manager_1 = __webpack_require__(289); const git_auth_helper_1 = __webpack_require__(287); const git_identity_helper_1 = __webpack_require__(723); const utils = __importStar(__webpack_require__(611)); -const DEFAULT_COMMIT_MESSAGE = '[create-pull-request] automated change'; -const DEFAULT_TITLE = 'Changes by create-pull-request action'; -const DEFAULT_BODY = 'Automated changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action'; -const DEFAULT_BRANCH = 'create-pull-request/patch'; function createPullRequest(inputs) { return __awaiter(this, void 0, void 0, function* () { let gitAuthHelper; @@ -10609,13 +10605,6 @@ function createPullRequest(inputs) { gitAuthHelper = new git_auth_helper_1.GitAuthHelper(git); yield gitAuthHelper.savePersistedAuth(); core.endGroup(); - // Set defaults - inputs.commitMessage = inputs.commitMessage - ? inputs.commitMessage - : DEFAULT_COMMIT_MESSAGE; - inputs.title = inputs.title ? inputs.title : DEFAULT_TITLE; - inputs.body = inputs.body ? inputs.body : DEFAULT_BODY; - inputs.branch = inputs.branch ? inputs.branch : DEFAULT_BRANCH; // Init the GitHub client const githubHelper = new github_helper_1.GitHubHelper(inputs.token); core.startGroup('Determining the base and head repositories'); diff --git a/src/create-pull-request.ts b/src/create-pull-request.ts index 953ca84..82d58c8 100644 --- a/src/create-pull-request.ts +++ b/src/create-pull-request.ts @@ -6,18 +6,15 @@ import {GitAuthHelper} from './git-auth-helper' import {GitIdentityHelper} from './git-identity-helper' import * as utils from './utils' -const DEFAULT_COMMIT_MESSAGE = '[create-pull-request] automated change' -const DEFAULT_TITLE = 'Changes by create-pull-request action' -const DEFAULT_BODY = - 'Automated changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action' -const DEFAULT_BRANCH = 'create-pull-request/patch' - export interface Inputs { token: string path: string commitMessage: string committer: string author: string + branch: string + base: string + pushToFork: string title: string body: string labels: string[] @@ -26,9 +23,6 @@ export interface Inputs { teamReviewers: string[] milestone: number draft: boolean - branch: string - pushToFork: string - base: string } export async function createPullRequest(inputs: Inputs): Promise { @@ -45,14 +39,6 @@ export async function createPullRequest(inputs: Inputs): Promise { await gitAuthHelper.savePersistedAuth() core.endGroup() - // Set defaults - inputs.commitMessage = inputs.commitMessage - ? inputs.commitMessage - : DEFAULT_COMMIT_MESSAGE - inputs.title = inputs.title ? inputs.title : DEFAULT_TITLE - inputs.body = inputs.body ? inputs.body : DEFAULT_BODY - inputs.branch = inputs.branch ? inputs.branch : DEFAULT_BRANCH - // Init the GitHub client const githubHelper = new GitHubHelper(inputs.token) diff --git a/src/main.ts b/src/main.ts index 14da30e..93ee2fa 100644 --- a/src/main.ts +++ b/src/main.ts @@ -11,6 +11,9 @@ async function run(): Promise { commitMessage: core.getInput('commit-message'), committer: core.getInput('committer'), author: core.getInput('author'), + branch: core.getInput('branch'), + base: core.getInput('base'), + pushToFork: core.getInput('push-to-fork'), title: core.getInput('title'), body: core.getInput('body'), labels: utils.getInputAsArray('labels'), @@ -18,10 +21,7 @@ async function run(): Promise { reviewers: utils.getInputAsArray('reviewers'), teamReviewers: utils.getInputAsArray('team-reviewers'), milestone: Number(core.getInput('milestone')), - draft: core.getInput('draft') === 'true', - branch: core.getInput('branch'), - pushToFork: core.getInput('push-to-fork'), - base: core.getInput('base') + draft: core.getInput('draft') === 'true' } core.debug(`Inputs: ${inspect(inputs)}`)