Skip to content

Commit 73648fe

Browse files
Fix #10 - add options and catch the boolean error (#11)
* Fix #10 - add options and catch the boolean error * Apply suggestions from code review Co-authored-by: Michal Vanko <[email protected]> Co-authored-by: Michal Vanko <[email protected]>
1 parent eb74ba7 commit 73648fe

5 files changed

Lines changed: 28 additions & 9 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
name: Copy labels from linked issues
2020
steps:
2121
- name: copy-labels
22-
uses: michalvankodev/[email protected].0
22+
uses: michalvankodev/[email protected].1
2323
with:
2424
repo-token: ${{ secrets.GITHUB_TOKEN }}
2525
```
@@ -46,7 +46,7 @@ These keywords will not override github specified keywords.
4646
```yml
4747
steps:
4848
- name: copy-labels
49-
uses: michalvankodev/[email protected].0
49+
uses: michalvankodev/[email protected].1
5050
with:
5151
repo-token: ${{ secrets.GITHUB_TOKEN }}
5252
custom-keywords: |
@@ -61,7 +61,7 @@ You can provide from-title = true to parse the issue numbers from title
6161
```yml
6262
steps:
6363
- name: copy-labels
64-
uses: michalvankodev/[email protected].0
64+
uses: michalvankodev/[email protected].1
6565
with:
6666
repo-token: ${{ secrets.GITHUB_TOKEN }}
6767
from-title: true

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ inputs:
88
description: 'The GITHUB_TOKEN secret'
99
custom-keywords:
1010
description: 'List of custom keywords which should be included in the parser'
11+
from-title:
12+
description: 'To parse the issue numbers from title, a boolean'
13+
required: false
1114
runs:
1215
using: 'node12'
1316
main: 'dist/index.js'

dist/index.js

Lines changed: 11 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,18 @@ function getInputAsArray(name: string, options?: core.InputOptions): string[] {
1414
.filter((x) => x !== '')
1515
}
1616

17+
function getBooleanInput(name: string, options?: core.InputOptions, defaultValue: boolean = false): boolean {
18+
try {
19+
return core.getBooleanInput(name, options)
20+
} catch (ex) {
21+
return defaultValue
22+
}
23+
}
24+
1725
async function run() {
1826
const token = core.getInput('repo-token', { required: true })
1927
const customKeywords = getInputAsArray('custom-keywords', { required: false })
20-
const fromTitle = core.getBooleanInput('from-title', { required: false })
28+
const fromTitle = getBooleanInput('from-title', { required: false })
2129

2230
const issueNumber = getIssueNumber(
2331
core.getInput('issue-number', { required: false })
@@ -66,7 +74,7 @@ async function run() {
6674
}, [])
6775
)
6876

69-
await client.issues.addLabels({
77+
labels.length > 0 && await client.issues.addLabels({
7078
owner: github.context.repo.owner,
7179
repo: github.context.repo.repo,
7280
issue_number: issueNumber,

0 commit comments

Comments
 (0)