Skip to content

Commit

Permalink
Fix #10 - add options and catch the boolean error (#11)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
microdataxyz and michalvankodev authored Jan 13, 2023
1 parent eb74ba7 commit 73648fe
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
name: Copy labels from linked issues
steps:
- name: copy-labels
uses: michalvankodev/[email protected].0
uses: michalvankodev/[email protected].1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
```
Expand All @@ -46,7 +46,7 @@ These keywords will not override github specified keywords.
```yml
steps:
- name: copy-labels
uses: michalvankodev/[email protected].0
uses: michalvankodev/[email protected].1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
custom-keywords: |
Expand All @@ -61,7 +61,7 @@ You can provide from-title = true to parse the issue numbers from title
```yml
steps:
- name: copy-labels
uses: michalvankodev/[email protected].0
uses: michalvankodev/[email protected].1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
from-title: true
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ inputs:
description: 'The GITHUB_TOKEN secret'
custom-keywords:
description: 'List of custom keywords which should be included in the parser'
from-title:
description: 'To parse the issue numbers from title, a boolean'
required: false
runs:
using: 'node12'
main: 'dist/index.js'
14 changes: 11 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.

12 changes: 10 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,18 @@ function getInputAsArray(name: string, options?: core.InputOptions): string[] {
.filter((x) => x !== '')
}

function getBooleanInput(name: string, options?: core.InputOptions, defaultValue: boolean = false): boolean {
try {
return core.getBooleanInput(name, options)
} catch (ex) {
return defaultValue
}
}

async function run() {
const token = core.getInput('repo-token', { required: true })
const customKeywords = getInputAsArray('custom-keywords', { required: false })
const fromTitle = core.getBooleanInput('from-title', { required: false })
const fromTitle = getBooleanInput('from-title', { required: false })

const issueNumber = getIssueNumber(
core.getInput('issue-number', { required: false })
Expand Down Expand Up @@ -66,7 +74,7 @@ async function run() {
}, [])
)

await client.issues.addLabels({
labels.length > 0 && await client.issues.addLabels({
owner: github.context.repo.owner,
repo: github.context.repo.repo,
issue_number: issueNumber,
Expand Down

0 comments on commit 73648fe

Please sign in to comment.