Skip to content

Commit 8d3e930

Browse files
coloursofnoisedscho
authored andcommitted
Allow user to specify API reasonFilter
1 parent bb6fc7f commit 8d3e930

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ inputs:
2828
required: false
2929
description: 'Use @actions/cache to accelerate this Action'
3030
default: 'true'
31+
reasonFilter:
32+
required: false
33+
description: 'Filter results by the reason for the build; Defaults to "all"'
34+
default: 'all'
3135
runs:
3236
using: 'node12'
3337
main: 'dist/index.js'

main.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ async function run(): Promise<void> {
1515
core.getInput('repository'),
1616
core.getInput('definitionId'),
1717
core.getInput('artifact'),
18-
core.getInput('stripPrefix')
18+
core.getInput('stripPrefix'),
19+
core.getInput('reasonFilter')
1920
)
2021
const outputDirectory = core.getInput('path') || artifactName
2122
let useCache = core.getInput('cache') === 'true'

src/downloader.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ export async function get(
115115
repository: string,
116116
definitionId: string,
117117
artifactName: string,
118-
stripPrefix?: string
118+
stripPrefix?: string,
119+
reasonFilter = 'all'
119120
): Promise<{
120121
artifactName: string
121122
stripPrefix: string
@@ -137,7 +138,7 @@ export async function get(
137138
count: number
138139
value: [{id: string; downloadURL: string}]
139140
}>(
140-
`${baseURL}?definitions=${definitionId}&statusFilter=completed&resultFilter=succeeded&$top=1`
141+
`${baseURL}?definitions=${definitionId}&statusFilter=completed&resultFilter=succeeded&reasonFilter=${reasonFilter}&$top=1`
141142
)
142143
if (data.count !== 1) {
143144
throw new Error(`Unexpected number of builds: ${data.count}`)

0 commit comments

Comments
 (0)