Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: implement silentFailure config and outputs.failure #106

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: silentFailure and outputs.failure
  • Loading branch information
znarf committed Dec 12, 2019
commit 1f57fc5a0bea0e28088b1b4cfec97661d0d42e1a
8 changes: 7 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions src/git-source-provider.ts
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@ export interface ISourceSettings {
fetchDepth: number
lfs: boolean
accessToken: string
silentFailure: boolean
}

export async function getSource(settings: ISourceSettings): Promise<void> {
4 changes: 4 additions & 0 deletions src/input-helper.ts
Original file line number Diff line number Diff line change
@@ -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
}
11 changes: 10 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -19,7 +19,16 @@ async function run(): Promise<void> {
)

// 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'}, '')