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

Add missing argument failIfEmpty #261

Merged
merged 1 commit into from
Oct 27, 2024
Merged
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
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,17 @@ lychee arguments can be passed to the action via the `args` parameter.

On top of that, the action also supports some additional arguments.

| Argument | Examples | Description |
| ------------- | ----------------------- | -------------------------------------------------------------------------------- |
| Argument | Examples | Description |
| ------------- | ----------------------- | ------------------------------------------------------------------------------- |
| args | `--cache`, `--insecure` | See [lychee's documentation][lychee-args] for all arguments and values |
| debug | `false` | Enable debug output in action (set -x). Helpful for troubleshooting |
| fail | `false` | Fail workflow run on error (i.e. when [lychee exit code][lychee-exit] is not 0) |
| failIfEmpty | `false` | Fail entire pipeline if no links were found |
| format | `markdown`, `json` | Summary output format |
| jobSummary | `false` | Write GitHub job summary (on Markdown output only) |
| lycheeVersion | `v0.15.0`, `nightly` | Overwrite the lychee version to be used |
| output | `lychee/results.md` | Summary output file path |
| token | `""` | Custom GitHub token to use for API calls |
| token | `""` | Custom GitHub token to use for API calls |

See [action.yml](./action.yml) for a full list of supported arguments and their default values.

Expand All @@ -79,7 +80,7 @@ Here is how to pass the arguments.
format: json
# Use different output file path
output: /tmp/foo.txt
# Use a custom GitHub token, which
# Use a custom GitHub token, which
token: ${{ secrets.CUSTOM_TOKEN }}
# Don't fail action on broken links
fail: false
Expand Down Expand Up @@ -113,6 +114,7 @@ So in this setup, as long as a user triggers the CI run from the same commit, it
For restoring the cache, the most recent available one is used (commit hash doesn't matter).

If you need more control over when caches are restored and saved, you can split the cache step and e.g. ensure to always save the cache (also when the link check step fails):

```yml
- name: Restore lychee cache
id: restore-cache
Expand Down
4 changes: 2 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ eval lychee ${FORMAT} --output ${LYCHEE_TMP} ${ARGS}
exit_code=$?

# Overwrite the exit code in case no links were found
# and `fail-if-empty` is set to `true` (and it is by default)
# and `failIfEmpty` is set to `true` (and it is by default)
if [ "${INPUT_FAILIFEMPTY}" = "true" ]; then
# Explicitly set INPUT_FAIL to true to ensure the script fails
# if no links are found
INPUT_FAIL=true
# This is a somewhat crude way to check the Markdown output of lychee
if grep -E 'Total\s+\|\s+0' "${LYCHEE_TMP}"; then
echo "No links were found. This usually indicates a configuration error." >> "${LYCHEE_TMP}"
echo "If this was expected, set 'fail-if-empty: false' in the args." >> "${LYCHEE_TMP}"
echo "If this was expected, set 'failIfEmpty: false' in the args." >> "${LYCHEE_TMP}"
exit_code=1
fi
fi
Expand Down
Loading