mirror of
https://code.forgejo.org/actions/checkout.git
synced 2024-11-28 06:59:16 +01:00
feat: silentFailure and outputs.failure
This commit is contained in:
parent
cab31617d8
commit
1f57fc5a0b
4 changed files with 22 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
||||||
name: 'Checkout'
|
name: 'Checkout'
|
||||||
description: 'Checkout a Git repository at a particular version'
|
description: 'Checkout a Git repository at a particular version'
|
||||||
inputs:
|
inputs:
|
||||||
repository:
|
repository:
|
||||||
description: 'Repository name with owner. For example, actions/checkout'
|
description: 'Repository name with owner. For example, actions/checkout'
|
||||||
default: ${{ github.repository }}
|
default: ${{ github.repository }}
|
||||||
|
@ -23,6 +23,12 @@ inputs:
|
||||||
lfs:
|
lfs:
|
||||||
description: 'Whether to download Git-LFS files'
|
description: 'Whether to download Git-LFS files'
|
||||||
default: false
|
default: false
|
||||||
|
silentFailure:
|
||||||
|
description: 'Whether to silent failure'
|
||||||
|
default: false
|
||||||
|
outputs:
|
||||||
|
failure:
|
||||||
|
description: 'A boolean value to indicate if the checkout failed'
|
||||||
runs:
|
runs:
|
||||||
using: node12
|
using: node12
|
||||||
main: dist/index.js
|
main: dist/index.js
|
||||||
|
|
|
@ -20,6 +20,7 @@ export interface ISourceSettings {
|
||||||
fetchDepth: number
|
fetchDepth: number
|
||||||
lfs: boolean
|
lfs: boolean
|
||||||
accessToken: string
|
accessToken: string
|
||||||
|
silentFailure: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getSource(settings: ISourceSettings): Promise<void> {
|
export async function getSource(settings: ISourceSettings): Promise<void> {
|
||||||
|
|
|
@ -100,5 +100,9 @@ export function getInputs(): ISourceSettings {
|
||||||
// Access token
|
// Access token
|
||||||
result.accessToken = core.getInput('token')
|
result.accessToken = core.getInput('token')
|
||||||
|
|
||||||
|
// Silent Failure
|
||||||
|
result.silentFailure =
|
||||||
|
(core.getInput('silentFailure') || 'false').toUpperCase() === 'TRUE'
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
11
src/main.ts
11
src/main.ts
|
@ -19,7 +19,16 @@ async function run(): Promise<void> {
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get sources
|
// Get sources
|
||||||
await gitSourceProvider.getSource(sourceSettings)
|
try {
|
||||||
|
await gitSourceProvider.getSource(sourceSettings)
|
||||||
|
} catch (error) {
|
||||||
|
core.setOutput('failure', 'true')
|
||||||
|
if (sourceSettings.silentFailure) {
|
||||||
|
core.info(`Silent Failure: ${error.message}`)
|
||||||
|
} else {
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
// Unregister problem matcher
|
// Unregister problem matcher
|
||||||
coreCommand.issueCommand('remove-matcher', {owner: 'checkout-git'}, '')
|
coreCommand.issueCommand('remove-matcher', {owner: 'checkout-git'}, '')
|
||||||
|
|
Loading…
Reference in a new issue