Set defaults in action.yml

This commit is contained in:
Peter Evans 2020-07-19 15:09:44 +09:00
parent b5b1bc17a4
commit 6fa44e144d
4 changed files with 50 additions and 63 deletions

View file

@ -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<void> {
@ -45,14 +39,6 @@ export async function createPullRequest(inputs: Inputs): Promise<void> {
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)

View file

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