feat: silentFailure and outputs.failure

This commit is contained in:
François Hodierne 2019-12-12 08:29:51 +01:00
parent cab31617d8
commit 1f57fc5a0b
4 changed files with 22 additions and 2 deletions

View File

@ -23,6 +23,12 @@ inputs:
lfs:
description: 'Whether to download Git-LFS files'
default: false
silentFailure:
description: 'Whether to silent failure'
default: false
outputs:
failure:
description: 'A boolean value to indicate if the checkout failed'
runs:
using: node12
main: dist/index.js

View File

@ -20,6 +20,7 @@ export interface ISourceSettings {
fetchDepth: number
lfs: boolean
accessToken: string
silentFailure: boolean
}
export async function getSource(settings: ISourceSettings): Promise<void> {

View File

@ -100,5 +100,9 @@ export function getInputs(): ISourceSettings {
// Access token
result.accessToken = core.getInput('token')
// Silent Failure
result.silentFailure =
(core.getInput('silentFailure') || 'false').toUpperCase() === 'TRUE'
return result
}

View File

@ -19,7 +19,16 @@ async function run(): Promise<void> {
)
// Get sources
try {
await gitSourceProvider.getSource(sourceSettings)
} catch (error) {
core.setOutput('failure', 'true')
if (sourceSettings.silentFailure) {
core.info(`Silent Failure: ${error.message}`)
} else {
throw error
}
}
} finally {
// Unregister problem matcher
coreCommand.issueCommand('remove-matcher', {owner: 'checkout-git'}, '')