Skip to content

Commit

Permalink
Fix michalvankodev#10 - add options and catch the boolean error
Browse files Browse the repository at this point in the history
  • Loading branch information
microdataxyz committed Jan 11, 2023
1 parent eb74ba7 commit 02f7200
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/copy-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
name: Copy labels from linked issues
steps:
- name: copy-labels
uses: michalvankodev/copy-issue-labels@v1.2.0
uses: michalvankodev/copy-issue-labels@v1.2.1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
custom-keywords: |
Expand Down
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/copy-issue-labels@v1.2.0
uses: michalvankodev/copy-issue-labels@v1.2.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/copy-issue-labels@v1.2.0
uses: michalvankodev/copy-issue-labels@v1.2.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/copy-issue-labels@v1.2.0
uses: michalvankodev/copy-issue-labels@v1.2.1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
from-title: true
Expand Down
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ 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'
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 02f7200

Please sign in to comment.