-
Notifications
You must be signed in to change notification settings - Fork 764
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
Add if-no-files-found option to merge action #521
Open
comp615
wants to merge
1
commit into
actions:main
Choose a base branch
from
comp615:merge_not_found
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ import * as core from '@actions/core' | |
import {Minimatch} from 'minimatch' | ||
import artifactClient, {UploadArtifactOptions} from '@actions/artifact' | ||
import {getInputs} from './input-helper' | ||
import {NoFileOptions} from '../shared/constants' | ||
import {uploadArtifact} from '../shared/upload-artifact' | ||
import {findFilesToUpload} from '../shared/search' | ||
|
||
|
@@ -32,7 +33,28 @@ export async function run(): Promise<void> { | |
) | ||
|
||
if (artifacts.length === 0) { | ||
throw new Error(`No artifacts found matching pattern '${inputs.pattern}'`) | ||
// No files were found, different use cases warrant different types of behavior if nothing is found | ||
switch (inputs.ifNoFilesFound) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would definitely add a default behavior of the switch statement emitting an error in case the value is something not yet know, even though the values are validated before. Just to make sure somebody implementing a new option can not forget it. |
||
case NoFileOptions.warn: { | ||
core.warning( | ||
`No artifacts were found with the provided pattern: ${inputs.pattern}.` | ||
) | ||
break | ||
} | ||
case NoFileOptions.error: { | ||
core.setFailed( | ||
`No artifacts were found with the provided pattern: ${inputs.pattern}.` | ||
) | ||
break | ||
} | ||
case NoFileOptions.ignore: { | ||
core.info( | ||
`No artifacts were found with the provided pattern: ${inputs.pattern}.` | ||
) | ||
break | ||
} | ||
} | ||
return; | ||
} | ||
|
||
core.info(`Preparing to download the following artifacts:`) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export enum NoFileOptions { | ||
/** | ||
* Default. Output a warning but do not fail the action | ||
*/ | ||
warn = 'warn', | ||
|
||
/** | ||
* Fail the action with an error message | ||
*/ | ||
error = 'error', | ||
|
||
/** | ||
* Do not output any warnings or errors, the action does not fail | ||
*/ | ||
ignore = 'ignore' | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK we're talking about artifacts, not files. That's why I would call it at least
if-no-artifacts-found
. However, some other wording options (I don't have a strong opinion here, just some thoughts to find a good solution):no-artifacts-behavior
/ options:["warn", "error", "ignore"]
no-artifacts-behavior
/ options:["exit-with-warning", "fail", "exit-gracefully"]