Skip to content

Commit

Permalink
Update pr
Browse files Browse the repository at this point in the history
  • Loading branch information
mre committed Apr 25, 2024
1 parent ad3b13a commit 905faa1
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 50 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/test.yml
Expand Up @@ -21,8 +21,6 @@ jobs:

- name: test defaults
uses: ./
with:
fail: true

- name: test explicit lychee version
uses: ./
Expand All @@ -39,7 +37,6 @@ jobs:
'./**/*.md'
'./**/*.html'
'./**/*.rst'
fail: true
- name: test --base argument
uses: ./
Expand All @@ -51,7 +48,6 @@ jobs:
'./**/*.md'
'./**/*.html'
'./**/*.rst'
fail: true
- name: test custom output relative path - creation
uses: ./
Expand Down Expand Up @@ -136,7 +132,6 @@ jobs:
args: -v fixtures/TEST.md
format: json
output: ${{ github.workspace }}/foo_md.json
fail: true

- name: Validate JSON - Markdown
run: |
Expand All @@ -151,7 +146,6 @@ jobs:
args: -v fixtures/TEST.rst
format: json
output: ${{ github.workspace }}/foo_rst.json
fail: true

- name: Validate JSON - rST
run: |
Expand All @@ -164,15 +158,13 @@ jobs:
uses: ./
with:
args: --exclude-mail .
fail: true

- name: test format override
uses: ./
with:
args: --format markdown -v fixtures/TEST.md
format: doesnotexist # gets ignored if format set in args
output: ${{ github.workspace }}/foo.txt
fail: true

- name: test debug
uses: ./
Expand Down
41 changes: 2 additions & 39 deletions README.md
Expand Up @@ -46,43 +46,6 @@ jobs:
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
requests. If there's an error, it will fail the action. This has the benefit of
ensuring that during a Pull Request, no link is added that is broken and any
existing link will be caught if they become broken. Save this under
`.github/workflows/links-fail-fast.yml`:

```yaml
name: Links (Fail Fast)

on:
push:
pull_request:

jobs:
linkChecker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Link Checker
uses: lycheeverse/lychee-action@v1.9.0
with:
fail: true
```

You may want to add additional arguments to the above. In particular, if you're testing a site directly from the file system (as in the above), you'll likely want to set the argument `--base .` to ensure that **all links** (including root-relative paths) in the files are tested. You don't need to do this if you're testing a hosted site.

```yaml
- name: Link Checker
uses: lycheeverse/lychee-action@v1.9.0
with:
fail: true
args: --base . --verbose --no-progress './**/*.md' './**/*.html' './**/*.rst'
```

## Passing arguments

This action uses [lychee] for link checking.
Expand Down Expand Up @@ -119,8 +82,8 @@ Here is how to pass the arguments.
output: /tmp/foo.txt
# Use a custom GitHub token, which
token: ${{ secrets.CUSTOM_TOKEN }}
# Fail action on broken links
fail: true
# Don't fail action on broken links
fail: false
```

(If you need a token that requires permissions that aren't available in the
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Expand Up @@ -11,7 +11,7 @@ inputs:
required: false
fail:
description: "Fail entire pipeline on error (i.e. when lychee exit code is not 0)"
default: false
default: true
required: false
failIfEmpty:
description: "Fail entire pipeline if no links were found"
Expand Down
5 changes: 3 additions & 2 deletions entrypoint.sh
Expand Up @@ -64,8 +64,9 @@ fi
# Pass lychee exit code to next step
echo "lychee_exit_code=$exit_code" >> $GITHUB_ENV

# If `fail` is set to `true`, propagate the real exit code to the workflow
# runner. This will cause the pipeline to fail on `exit != 0`.
# If `fail` is set to `true` (and it is by default), propagate the real exit
# value to the workflow runner. This will cause the pipeline to fail on
# `exit != # 0`.
if [ "$INPUT_FAIL" = true ] ; then
exit ${exit_code}
fi

0 comments on commit 905faa1

Please sign in to comment.