Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiaanspeck authored Nov 1, 2024
2 parents 0adf18c + ae46991 commit 59f818a
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
jobs:
linkChecker:
runs-on: ubuntu-latest
permissions:
issues: write # required for peter-evans/create-issue-from-file
steps:
- uses: actions/checkout@v4

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ jobs:
debug: true
continue-on-error: true

# Explictly check the exit code of the previous step
# Explicitly check the exit code of the previous step
# as it's expected to fail
- name: Check failIfEmpty
if: steps.fail_if_empty_test.outcome != 'failure'
Expand Down
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Quickly check links in Markdown, HTML, and text files using [lychee].

When used in conjunction with [Create Issue From File], issues will be
opened when the action finds link problems.
opened when the action finds link problems (make sure to specify the `issues: write` permission in the [workflow](https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#permissions) or the [job](https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idpermissions)).

## Usage

Expand All @@ -27,6 +27,8 @@ on:
jobs:
linkChecker:
runs-on: ubuntu-latest
permissions:
issues: write # required for peter-evans/create-issue-from-file
steps:
- uses: actions/checkout@v4

Expand All @@ -50,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 @@ -77,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 @@ -111,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
5 changes: 5 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Security Policy

## Reporting a Vulnerability

To report a vulnerability in lychee-action, [open a private vulnerability report](https://github.com/lycheeverse/lychee-action/security/advisories/new) and you can create a patch on a private fork or, after reporting the problem, our maintainers will fix it as soon as possible.
14 changes: 8 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,17 @@ runs:
id: lychee-setup
run: |
# Determine filename and download URL based on version
if [[ '${{ inputs.lycheeVersion }}' =~ ^v0\.0|^v0\.1[0-5]\. ]]; then
FILENAME="lychee-${{ inputs.lycheeVersion }}-x86_64-unknown-linux-gnu.tar.gz"
DOWNLOAD_URL="https://github.com/lycheeverse/lychee/releases/download/${{ inputs.lycheeVersion }}/${FILENAME}"
if [[ "${LYCHEE_VERSION}" =~ ^v0\.0|^v0\.1[0-5]\. ]]; then
FILENAME="lychee-${LYCHEE_VERSION}-x86_64-unknown-linux-gnu.tar.gz"
DOWNLOAD_URL="https://github.com/lycheeverse/lychee/releases/download/${LYCHEE_VERSION}/${FILENAME}"
else
FILENAME="lychee-x86_64-unknown-linux-gnu.tar.gz"
if [[ '${{ inputs.lycheeVersion }}' == 'nightly' ]]; then
if [[ "${LYCHEE_VERSION}" == 'nightly' ]]; then
DOWNLOAD_URL="https://github.com/lycheeverse/lychee/releases/download/nightly/${FILENAME}"
elif [[ '${{ inputs.lycheeVersion }}' == 'latest' ]]; then
elif [[ "${LYCHEE_VERSION}" == 'latest' ]]; then
DOWNLOAD_URL="https://github.com/lycheeverse/lychee/releases/latest/download/${FILENAME}"
else
DOWNLOAD_URL="https://github.com/lycheeverse/lychee/releases/download/lychee-${{ inputs.lycheeVersion }}/${FILENAME}"
DOWNLOAD_URL="https://github.com/lycheeverse/lychee/releases/download/lychee-${LYCHEE_VERSION}/${FILENAME}"
fi
fi
Expand All @@ -87,6 +87,8 @@ runs:
# Output filename for use in later steps
echo "filename=${FILENAME}" >> $GITHUB_OUTPUT
env:
LYCHEE_VERSION: ${{ inputs.lycheeVersion }}
shell: bash

- name: Install lychee
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

0 comments on commit 59f818a

Please sign in to comment.