Skip to content

Commit

Permalink
Handle empty pull requests
Browse files Browse the repository at this point in the history
  • Loading branch information
sbimochan committed Dec 27, 2021
1 parent 4d1f345 commit e474dc6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
uses: actions/checkout@v1

- name: Append ticket link
uses: sbimochan/ticket-link-appender@v1.11
uses: sbimochan/ticket-link-appender@v1.12

with:
jira-project-url: https://jira.atlassian.net/browse
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Jira Link: https://jira.atlassian.net/browse/JPT-1571
`custom-comment` is (optional)

```yaml
uses: sbimochan/ticket-link-appender@v1.11
uses: sbimochan/ticket-link-appender@v1.12
with:
jira-project-url: https://jira.atlassian.net/browse
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -43,7 +43,7 @@ jobs:
uses: actions/checkout@v1

- name: Append ticket link
uses: sbimochan/ticket-link-appender@v1.11
uses: sbimochan/ticket-link-appender@v1.12

with:
jira-project-url: https://jira.atlassian.net/browse
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ticket-link-appender",
"version": "1.11.0",
"version": "1.12.0",
"description": "Appends jira or any other project ticket link to PR description",
"main": "src/main.js",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ function grabTicket(title) {
* @returns {string} Updated body string.
*/
function appendLinkInDescription(context) {
const prevBody = context.payload.pull_request.body;
const prevBody = context.payload.pull_request.body || '';
const ticketNumber = grabTicket(context.payload.pull_request.title);

if (!ticketNumber) {
return;
}

const updatedBody = `${prevBody} \n\n ----- \nJira link: ${
jirProjectUrl + '/' + ticketNumber
}`;
Expand Down

0 comments on commit e474dc6

Please sign in to comment.