Skip to content

Feature: implement silentFailure config and outputs.failure #106

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ Refer [here](https://github.com/actions/checkout/blob/v1/README.md) for previous
# Whether to download Git-LFS files
# Default: false
lfs: ''

# Whether to silent failure
# Default: false
silentFailure: ''
```
<!-- end usage -->

Expand Down
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 }}
Expand All @@ -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
Expand Down
16 changes: 15 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2611,7 +2611,18 @@ function run() {
// Register problem matcher
coreCommand.issueCommand('add-matcher', {}, path.join(__dirname, 'problem-matcher.json'));
// Get sources
yield gitSourceProvider.getSource(sourceSettings);
try {
yield 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
Expand Down Expand Up @@ -10405,6 +10416,9 @@ function getInputs() {
core.debug(`lfs = ${result.lfs}`);
// Access token
result.accessToken = core.getInput('token');
// Silent Failure
result.silentFailure =
(core.getInput('silentFailure') || 'false').toUpperCase() === 'TRUE';
return result;
}
exports.getInputs = getInputs;
Expand Down
1 change: 1 addition & 0 deletions src/git-source-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface ISourceSettings {
fetchDepth: number
lfs: boolean
accessToken: string
silentFailure: boolean
}

export async function getSource(settings: ISourceSettings): Promise<void> {
Expand Down
4 changes: 4 additions & 0 deletions src/input-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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'}, '')
Expand Down