Skip to content

Commit b590eac

Browse files
authored
Add safe guard for title before sending to github api (#265)
1 parent dc67d17 commit b590eac

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

.changeset/small-icons-behave.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'davinci-github-actions': patch
3+
---
4+
5+
- add safeguard to not send empty title to github api

pr-conventional-to-toptal-commits/action.yml

+8-3
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,21 @@ runs:
2121
const pattern = /^\w+(?:\(.+\))?: (.*)$/
2222
const [, titleMessage = ''] = title.match(pattern) ?? []
2323
24-
return capitalize(titleMessage.trim()) ?? title
24+
return capitalize(titleMessage.trim()) || title
2525
}
2626
27+
const oldTitle = context.payload.pull_request.title
28+
const updatedTitle = convertConventional(oldTitle)
29+
2730
const newPr = {
2831
owner: context.repo.owner,
2932
repo: context.repo.repo,
3033
pull_number: context.payload.pull_request.number,
31-
title: convertConventional(context.payload.pull_request.title)
34+
title: updatedTitle,
3235
}
3336
34-
github.rest.pulls.update(newPr);
37+
if (oldTitle !== updatedTitle) {
38+
github.rest.pulls.update(newPr);
39+
}
3540
3641

0 commit comments

Comments
 (0)