Skip to content

Commit

Permalink
feat: support custom pr title suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorhugods committed Apr 29, 2024
1 parent a69fbf7 commit 9a43caf
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
uses: ./
with:
target-branch: 'main'
pr-title-suffix: '🍒'
- name: Get the output
run:
echo "The created PR number is ${{
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive #If you need to operate on submodules

- name: Cherry pick
id: cherry-pick
uses: ./
with:
target-branch: 'develop' # Branch which will receive the automatic cherry-picks
submodule-name: 'nameOfTheSubmodule' # If you want the action to fast-forward the submodule
pr-title-suffix: '🍒'

- name: Get the output
run:
Expand Down
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ inputs:
'Comma-separated list of labels to add to this PR. Empty by default'
required: false
default: ''
pr-title-suffix:
description:
'(optional) suffix to be added to the title of the created PR.
[Cherry-Pick] by default'
required: false
default: '[Cherry-Pick]'

outputs:
pr-number:
Expand Down
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export async function run(): Promise<void> {
const targetBranch = core.getInput('target-branch')
const githubToken = core.getInput('pr-creator-token')
const submoduleName = core.getInput('submodule-name')
const prTitleSuffix = core.getInput('pr-title-suffix')
let prAssignee = core.getInput('pr-assignee')
if (prAssignee === '' && mergedPR.assignee != null) {
// Use the assignee of the original PR as the assignee of the cherry-pick
Expand Down Expand Up @@ -95,9 +96,11 @@ export async function run(): Promise<void> {
// Delete submodule update temporary branch
await gitExec(['branch', '-D', tempBranchName])
}
const prTitle = `${mergedPR.title} ${prTitleSuffix}`
const resultPrNumber = await createPullRequest(
githubToken,
mergedPR,
prTitle,
newBranchName,
targetBranch
)
Expand Down
2 changes: 1 addition & 1 deletion src/pr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as github from '@actions/github'
export async function createPullRequest(
githubToken: string,
mergedPR: PullRequest,
prTitle: string,
newBranchName: string,
targetBranch: string
): Promise<number> {
Expand All @@ -24,7 +25,6 @@ export async function createPullRequest(
- #${mergedPR.number}\n
${originalPrBodyMessage}
`
const prTitle = `${mergedPR.title} [Cherry-Pick]`
const resultPr = await octokit.rest.pulls.create({
owner: repoOwner,
repo: repoName,
Expand Down

0 comments on commit 9a43caf

Please sign in to comment.