Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: lycheeverse/lychee-action
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.5.1
Choose a base ref
...
head repository: lycheeverse/lychee-action
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.5.2
Choose a head ref
  • 10 commits
  • 5 files changed
  • 6 contributors

Commits on Jul 27, 2022

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    6bbdba0 View commit details

Commits on Aug 10, 2022

  1. fix readme (#154)

    eryajf authored Aug 10, 2022
    Copy the full SHA
    d54f290 View commit details
  2. docs: bump version in README (#156)

    * bump version
    
    * bump secure version example
    tooomm authored Aug 10, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    ee1a5b5 View commit details

Commits on Aug 11, 2022

  1. Verified

    This commit was signed with the committer’s verified signature.
    msclock l.feng
    Copy the full SHA
    de3ad1c View commit details
  2. Add note about v1

    mre authored Aug 11, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    9e5d9ec View commit details
  3. Order args alphabetically (#159)

    mre authored Aug 11, 2022

    Partially verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
    Copy the full SHA
    c2c86e5 View commit details
  4. Add debug argument (#160)

    mre authored Aug 11, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    2e991c5 View commit details

Commits on Aug 29, 2022

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    eb40205 View commit details

Commits on Oct 23, 2022

  1. Replace deprecated ::set-output by $GITHUB_ENV (#167)

    Signed-off-by: Yury-Fridlyand <yuryf@bitquilltech.com>
    Yury-Fridlyand authored Oct 23, 2022
    Copy the full SHA
    2fa80ee View commit details

Commits on Nov 3, 2022

  1. Bump actions/checkout from 3.0.2 to 3.1.0 (#165)

    Bumps [actions/checkout](https://github.com/actions/checkout) from 3.0.2 to 3.1.0.
    - [Release notes](https://github.com/actions/checkout/releases)
    - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
    - [Commits](actions/checkout@2541b12...93ea575)
    
    ---
    updated-dependencies:
    - dependency-name: actions/checkout
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Nov 3, 2022
    Copy the full SHA
    25f59e1 View commit details
Showing with 86 additions and 42 deletions.
  1. +1 −1 .github/workflows/links.yml
  2. +5 −1 .github/workflows/main.yml
  3. +55 −26 README.md
  4. +17 −12 action.yml
  5. +8 −2 entrypoint.sh
2 changes: 1 addition & 1 deletion .github/workflows/links.yml
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ jobs:
linkChecker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8

- name: Link Checker
uses: ./ # Uses an action in the root directory
6 changes: 5 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ jobs:
# To use this repository's private action,
# we must check out the repository
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
- name: test defaults
uses: ./
with:
@@ -46,3 +46,7 @@ jobs:
format: doesnotexist # gets ignored if format set in args
output: /tmp/foo.txt
fail: true
- name: test debug
uses: ./
with:
debug: true
81 changes: 55 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -5,9 +5,8 @@

Quickly check links in Markdown, HTML, and text files using [lychee].

When used in conjunction with [Create Issue From
File](https://github.com/peter-evans/create-issue-from-file), issues will be
created when the action finds link problems.
When used in conjunction with [Create Issue From File], issues will be
opened when the action finds link problems.

## Usage

@@ -33,19 +32,22 @@ jobs:

- name: Link Checker
id: lychee
uses: lycheeverse/lychee-action@v1.5.0
uses: lycheeverse/lychee-action@v1.5.1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Create Issue From File
if: steps.lychee.outputs.exit_code != 0
uses: peter-evans/create-issue-from-file@v3
if: env.lychee_exit_code != 0
uses: peter-evans/create-issue-from-file@v4
with:
title: Link Checker Report
content-filepath: ./lychee/out.md
labels: report, automated issue
```
If you always want to use the latest features but avoid breaking changes, you can replace the version with
`lycheeverse/lychee-action@v1`.

### Alternative approach:

This will check all repository links during any git push event and for all pull
@@ -68,7 +70,7 @@ jobs:
- uses: actions/checkout@v3
- name: Link Checker
uses: lycheeverse/lychee-action@v1.5.0
uses: lycheeverse/lychee-action@v1.5.1
with:
fail: true
env:
@@ -82,22 +84,23 @@ 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 |
| ------------- | ----------------------- |-------------------------------------------------------------------------------- |
| args | `--cache`, `--insecure` | See [lychee's documentation][lychee-args] for all arguments and values |
| format | `markdown`, `json` | Summary output format |
| output | `lychee/results.md` | Summary output file path |
| fail | `false` | Fail workflow run on error (i.e. when [lychee exit code][lychee-exit] is not 0) |
| jobSummary | `false` | Write Github job summary (on Markdown output only) |
| lycheeVersion | `0.10.0` | Overwrite the lychee version to be used |
| 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). |
| format | `markdown`, `json` | Summary output format. |
| jobSummary | `false` | Write Github job summary (on Markdown output only). |
| lycheeVersion | `0.10.1` | Overwrite the lychee version to be used. |
| output | `lychee/results.md` | Summary output file path. |

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

### Example of argument passing

```yml
- name: Link Checker
uses: lycheeverse/lychee-action@v1.5.0
uses: lycheeverse/lychee-action@v1.5.1
with:
# Check all markdown and html files in repo (default)
args: --verbose --no-progress './**/*.md' './**/*.html'
@@ -109,6 +112,31 @@ See [action.yml](./action.yml) for a full list of supported arguments and their
fail: true
```

## Utilising the cache feature

In order to mitigate issues regarding rate limiting or to reduce stress on external resources, one can setup lychee's cache similar to this:

```yml
- name: Restore lychee cache
uses: actions/cache@v3
with:
path: .lycheecache
key: cache-lychee-${{ github.sha }}
restore-keys: cache-lychee-
- name: Run lychee
uses: lycheeverse/lychee-action@v1.5.1
with:
args: '--cache --max-cache-age 1d'
```

Note that there is no need for another step at the end to store the cache.
There will automatically be a `Post` step (generated from the used `actions/cache` action) taking care of that.
It will compare and save the cache based on the given key.
So in this setup, as long as a user triggers the CI run from the same commit, it will be the same key. The first run will save the cache, subsequent runs will not update it (because it's the same commit hash).
For restoring the cache, the most recent available one is used (commit hash doesn't matter).


## Excluding links from getting checked

Add a `.lycheeignore` file to the root of your repository to exclude links from
@@ -170,31 +198,32 @@ For example:

```yml
- name: Link Checker
uses: lycheeverse/lychee-action@cb79c9607b37671965f8dbb54cae47795758a440 #1.1.1
#...
uses: lycheeverse/lychee-action@4a5af7cd2958a2282cefbd9c10f63bdb89982d76 # for v1.5.1
```

## Credits

This action is based on
[peter-evans/link-checker](https://github.com/peter-evans/link-checker) and uses
lychee (written in Rust) instead of liche (written in Go) for link checking. For
a comparison of both tools, check out this [comparison
table](https://github.com/lycheeverse/lychee#features).
This action is based on the deprecated [peter-evans/link-checker] and uses
[lychee] (written in Rust) instead of liche (written in Go) for link checking.

## License

lychee is licensed under either of

- Apache License, Version 2.0, (LICENSE-APACHE or
https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://choosealicense.com/licenses/mit/)
- [Apache License, Version 2.0] ([LICENSE-APACHE](./LICENSE-APACHE))
- [MIT License] ([LICENSE-MIT](./LICENSE-MIT))

at your option.



[lychee]: https://github.com/lycheeverse/lychee
[lychee-args]: https://github.com/lycheeverse/lychee#commandline-parameters
[lychee-exit]: https://github.com/lycheeverse/lychee#exit-codes
[troubleshooting]: https://github.com/lycheeverse/lychee/blob/master/docs/TROUBLESHOOTING.md
[security]: https://francoisbest.com/posts/2020/the-security-of-github-actions
[dependabot]: https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
[peter-evans/link-checker]: https://github.com/peter-evans/link-checker
[Create Issue From File]: https://github.com/peter-evans/create-issue-from-file
[Apache License, Version 2.0]: https://www.apache.org/licenses/LICENSE-2.0
[MIT License]: https://choosealicense.com/licenses/mit
29 changes: 17 additions & 12 deletions action.yml
Original file line number Diff line number Diff line change
@@ -5,18 +5,18 @@ inputs:
description: "Lychee arguments (https://github.com/lycheeverse/lychee#commandline-parameters)"
default: "--verbose --no-progress './**/*.md' './**/*.html'"
required: false
format:
description: "Summary output format (e.g. json)"
default: "markdown"
required: false
output:
description: "Summary output file path"
default: "lychee/out.md"
debug:
description: "Enable debug output in action (set -x). Helpful for troubleshooting."
default: false
required: false
fail:
description: "Fail entire pipeline on error (i.e. when lychee exit code is not 0)"
default: false
required: false
format:
description: "Summary output format (e.g. json)"
default: "markdown"
required: false
jobSummary:
description: "Write Github job summary at the end of the job (written on Markdown output only)"
default: true
@@ -25,6 +25,10 @@ inputs:
description: "Use custom version of lychee link checker"
default: 0.10.1
required: false
output:
description: "Summary output file path"
default: "lychee/out.md"
required: false
outputs:
exit_code:
description: "The exit code returned from Lychee"
@@ -34,10 +38,10 @@ runs:
steps:
- name: Install lychee
run: |
curl -LO 'https://github.com/lycheeverse/lychee/releases/download/v${{ inputs.LYCHEEVERSION }}/lychee-v${{ inputs.LYCHEEVERSION }}-x86_64-unknown-linux-gnu.tar.gz'
curl -sLO 'https://github.com/lycheeverse/lychee/releases/download/v${{ inputs.LYCHEEVERSION }}/lychee-v${{ inputs.LYCHEEVERSION }}-x86_64-unknown-linux-gnu.tar.gz'
tar -xvzf lychee-v${{ inputs.LYCHEEVERSION }}-x86_64-unknown-linux-gnu.tar.gz
chmod 755 lychee
mv lychee /usr/local/bin/lychee
install -t $HOME/.local/bin -D lychee
echo "$HOME/.local/bin" >> $GITHUB_PATH
shell: bash
- name: Run lychee
run: ${{ github.action_path }}/entrypoint.sh
@@ -46,10 +50,11 @@ runs:
# https://github.com/actions/runner/issues/665
INPUT_GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
INPUT_ARGS: ${{ inputs.ARGS }}
INPUT_FORMAT: ${{ inputs.FORMAT }}
INPUT_OUTPUT: ${{ inputs.OUTPUT }}
INPUT_DEBUG: ${{ inputs.DEBUG }}
INPUT_FAIL: ${{ inputs.FAIL }}
INPUT_FORMAT: ${{ inputs.FORMAT }}
INPUT_JOBSUMMARY: ${{ inputs.JOBSUMMARY }}
INPUT_OUTPUT: ${{ inputs.OUTPUT }}
shell: bash
branding:
icon: "external-link"
10 changes: 8 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/bin/bash -l
set -uxo pipefail
set -uo pipefail

# Enable optional debug output
if [ "${INPUT_DEBUG}" = true ]; then
echo "Debug output enabled"
set -x
fi

LYCHEE_TMP="/tmp/lychee/out.md"
GITHUB_WORKFLOW_URL="https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}?check_suite_focus=true"
@@ -42,7 +48,7 @@ if [ "${INPUT_FORMAT}" == "markdown" ]; then
fi

# Pass lychee exit code to next step
echo ::set-output name=exit_code::$exit_code
echo "lychee_exit_code=$exit_code" >> $GITHUB_ENV

# If `fail` is set to `true`, propagate the real exit value to the workflow
# runner. This will cause the pipeline to fail on exit != 0.