Skip to content

Commit

Permalink
Allow release for do_not_skip input (#273)
Browse files Browse the repository at this point in the history
* Allow 'release' as option for 'do_not_skip' input
* Small optimizations
  * Use meaningful variable ('file' vs. 'f')
  * Remove unnecessary default values for boolean inputs
  * Directly return commit response (remove 'res' variable)
  • Loading branch information
paescuj committed Sep 22, 2022
1 parent 0eb36ff commit b807605
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -135,7 +135,7 @@ If true, skip if an already finished duplicate run can be found.

A JSON-array with triggers that should never be skipped.

Possible values are `pull_request`, `push`, `workflow_dispatch`, `schedule`.
Possible values are `pull_request`, `push`, `workflow_dispatch`, `schedule`, `release`.

**Default:** `'["workflow_dispatch", "schedule"]'`

Expand Down
18 changes: 10 additions & 8 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 15 additions & 10 deletions src/main.ts
Expand Up @@ -16,7 +16,8 @@ const workflowRunTriggerOptions = [
'pull_request',
'push',
'workflow_dispatch',
'schedule'
'schedule',
'release'
] as const
type WorkflowRunTrigger = typeof workflowRunTriggerOptions[number]

Expand Down Expand Up @@ -305,7 +306,9 @@ class SkipDuplicateActions {
}
iterSha = commit.parents?.length ? commit.parents[0]?.sha : null
const changedFiles = commit.files
? commit.files.map(f => f.filename).filter(f => typeof f === 'string')
? commit.files
.map(file => file.filename)
.filter(file => typeof file === 'string')
: []
allChangedFiles.push(changedFiles)

Expand Down Expand Up @@ -417,11 +420,12 @@ class SkipDuplicateActions {
return null
}
try {
const res = await this.context.octokit.rest.repos.getCommit({
...this.context.repo,
ref: sha
})
return res.data
return (
await this.context.octokit.rest.repos.getCommit({
...this.context.repo,
ref: sha
})
).data
} catch (error) {
if (error instanceof Error || typeof error === 'string') {
core.warning(error)
Expand All @@ -441,9 +445,10 @@ async function main(): Promise<void> {
pathsFilter: getPathsFilterInput('paths_filter'),
doNotSkip: getDoNotSkipInput('do_not_skip'),
concurrentSkipping: getConcurrentSkippingInput('concurrent_skipping'),
cancelOthers: core.getBooleanInput('cancel_others') ?? false,
skipAfterSuccessfulDuplicates:
core.getBooleanInput('skip_after_successful_duplicate') ?? true
cancelOthers: core.getBooleanInput('cancel_others'),
skipAfterSuccessfulDuplicates: core.getBooleanInput(
'skip_after_successful_duplicate'
)
}

const repo = github.context.repo
Expand Down

0 comments on commit b807605

Please sign in to comment.