From 1f57fc5a0bea0e28088b1b4cfec97661d0d42e1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franc=CC=A7ois=20Hodierne?= Date: Thu, 12 Dec 2019 08:29:51 +0100 Subject: [PATCH] feat: silentFailure and outputs.failure --- action.yml | 8 +++++++- src/git-source-provider.ts | 1 + src/input-helper.ts | 4 ++++ src/main.ts | 11 ++++++++++- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index d21e5f1..fa95d2c 100644 --- a/action.yml +++ b/action.yml @@ -1,6 +1,6 @@ name: 'Checkout' description: 'Checkout a Git repository at a particular version' -inputs: +inputs: repository: description: 'Repository name with owner. For example, actions/checkout' default: ${{ github.repository }} @@ -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 diff --git a/src/git-source-provider.ts b/src/git-source-provider.ts index fc41fd2..fff33b0 100644 --- a/src/git-source-provider.ts +++ b/src/git-source-provider.ts @@ -20,6 +20,7 @@ export interface ISourceSettings { fetchDepth: number lfs: boolean accessToken: string + silentFailure: boolean } export async function getSource(settings: ISourceSettings): Promise { diff --git a/src/input-helper.ts b/src/input-helper.ts index d7d8779..961a9e0 100644 --- a/src/input-helper.ts +++ b/src/input-helper.ts @@ -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 } diff --git a/src/main.ts b/src/main.ts index 26da3aa..caef941 100644 --- a/src/main.ts +++ b/src/main.ts @@ -19,7 +19,16 @@ async function run(): Promise { ) // 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 { // Unregister problem matcher coreCommand.issueCommand('remove-matcher', {owner: 'checkout-git'}, '')