From 9963ea2aa819d5b257e4e6d1d66b82b25b7bafea Mon Sep 17 00:00:00 2001 From: Philippe Laflamme <484152+plaflamme@users.noreply.github.com> Date: Thu, 8 Dec 2022 11:45:33 -0500 Subject: [PATCH] feat: add `pull-request-header` input (#615) Co-authored-by: Jeff Ching --- README.md | 1 + action.yml | 3 +++ index.js | 2 ++ test/release-please.js | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 39 insertions(+) diff --git a/README.md b/README.md index 5149f87..0c9fadb 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ Automate releases with Conventional Commit Messages. | `command` | release-please command to run, either `github-release`, or `release-pr`, `manifest`, `manifest-pr` (_defaults to running both_) | | `default-branch` | branch to open pull release PR against (detected by default) | | `pull-request-title-pattern` | title pattern used to make release PR, defaults to using `chore${scope}: release${component} ${version}`. | +| `pull-request-header` | header used within the release PR body, defaults to using `:robot: I have created a release *beep* *boop*`. | | `changelog-path` | configure alternate path for `CHANGELOG.md`. Default `CHANGELOG.md` | | `github-api-url` | configure github API URL. Default `https://api.github.com` | | `signoff` | Add [`Signed-off-by`](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---signoff) line at the end of the commit log message using the user and email provided. (format "Name \") | diff --git a/action.yml b/action.yml index c481f61..b7c85a1 100644 --- a/action.yml +++ b/action.yml @@ -91,6 +91,9 @@ inputs: pull-request-title-pattern: description: 'add title pattern to make release PR, defaults to using "chore${scope}: release${component} ${version}"' required: false + pull-request-header: + description: 'set release PR header, defaults to using ":robot: I have created a release *beep* *boop*"' + required: false draft: description: 'mark release as a draft' required: false diff --git a/index.js b/index.js index d4672ec..b19c659 100644 --- a/index.js +++ b/index.js @@ -141,6 +141,7 @@ async function manifestInstance (github) { const versionFile = core.getInput('version-file') || undefined const extraFiles = core.getMultilineInput('extra-files') || undefined const pullRequestTitlePattern = core.getInput('pull-request-title-pattern') || undefined + const pullRequestHeader = core.getInput('pull-request-header') || undefined const draft = getOptionalBooleanInput('draft') const draftPullRequest = getOptionalBooleanInput('draft-pull-request') const changelogType = core.getInput('changelog-notes-type') || undefined @@ -179,6 +180,7 @@ async function manifestInstance (github) { extraFiles, includeComponentInTag: monorepoTags, pullRequestTitlePattern, + pullRequestHeader, draftPullRequest, versioning, releaseAs, diff --git a/test/release-please.js b/test/release-please.js index 0fa6138..3e4d6af 100644 --- a/test/release-please.js +++ b/test/release-please.js @@ -159,6 +159,39 @@ describe('release-please-action', () => { ) }) + it('opens PR with custom header', async () => { + input = { + command: 'release-pr', + 'release-type': 'node', + 'pull-request-header': 'another header', + 'skip-github-release': 'false', + prerelease: 'false', + 'include-v-in-tag': 'true', + 'always-link-local': 'true', + 'separate-pull-requests': 'false', + 'skip-labeling': 'false', + 'sequential-calls': 'false' + } + + const createPullRequestsFake = sandbox.fake.returns([fixturePrs[0]]) + const createManifestCommand = sandbox.stub(Manifest, 'fromConfig').returns({ + createPullRequests: createPullRequestsFake + }) + await action.main() + + sinon.assert.calledOnce(createPullRequestsFake) + sinon.assert.calledWith( + createManifestCommand, + sinon.match.any, + 'main', + sinon.match.hasOwn( + 'pullRequestHeader', + 'another header' + ), + sinon.match.any + ) + }) + it('both opens PR to the default branch and tags GitHub releases by default', async () => { input = { 'skip-github-release': 'false',