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 support for Github Job Summaries #127

Merged
merged 4 commits into from
May 29, 2022
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
2 changes: 1 addition & 1 deletion LICENSE-APACHE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ APPENDIX: How to apply the Apache License to your work.
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2020 The lychee maintainers
Copyright 2022 The lychee maintainers

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 The lychee maintainers
Copyright (c) 2022 The lychee maintainers

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
79 changes: 48 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@

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](https://github.com/peter-evans/create-issue-from-file), issues will be
created when the action finds link problems.

## Usage

Here is a full example of a GitHub workflow file:

It will check all repository links once per day and create an issue in case of errors.
Save this under `.github/workflows/links.yml`:
It will check all repository links once per day and create an issue in case of
errors. Save this under `.github/workflows/links.yml`:

```yaml
name: Links
Expand All @@ -31,7 +33,7 @@ jobs:

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

Expand Down Expand Up @@ -66,7 +68,7 @@ jobs:
- uses: actions/checkout@v3

- name: Link Checker
uses: lycheeverse/lychee-action@v1.4.1
uses: lycheeverse/lychee-action@v1.5.0
with:
fail: true
env:
Expand All @@ -77,40 +79,45 @@ jobs:

This action uses [lychee] for link checking.
lychee arguments can be passed to the action via the `args` parameter.
On top of that, some other inputs are supported: `format`, `output`, and `fail`.
See [lychee's documentation][lychee-args] for all possible arguments.

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

| Argument | Description |
| ---------- | -------------------------------------------------------------------------------- |
| format | Summary output format (markdown, json,...) |
| output | Summary output file path |
| fail | Fail entire pipeline on error (i.e. when lychee exit code is not 0) |
| jobSummary | Write Github job summary at the end of the job (written on Markdown output only) |

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

### Example of argument passing

```yml
- name: Link Checker
uses: lycheeverse/lychee-action@v1.4.1
uses: lycheeverse/lychee-action@v1.5.0
with:
# Check all markdown and html files in repo (default)
args: --verbose --no-progress './**/*.md' './**/*.html'
# Use json as output format (instead of markdown)
format: json
# Use different output filename
# Use different output file path
output: /tmp/foo.txt
# Fail action on broken links
fail: true
```

See [lychee's documentation][lychee-args] for all possible arguments.

## Excluding links from getting checked

Add a `.lycheeignore` file to the root of your repository to exclude links from
getting checked. It supports regular expressions. One expression per line.

## Optional environment variables

Issues with links will be written to a file containing the error report.
The default path is `lychee/out.md`. The path and filename may be overridden with the following variable:

- `LYCHEE_OUT` - The path to the output file for the Markdown error report

## Fancy badge

Pro tip: You can add a little badge to your repo to show the status of your links.
Just replace `org` with your organisation name and `repo` with the repository name and put it into your `README.md`:
Pro tip: You can add a little badge to your repo to show the status of your
links. Just replace `org` with your organisation name and `repo` with the
repository name and put it into your `README.md`:

```
[![Check Links](https://github.com/org/repo/actions/workflows/links.yml/badge.svg)](https://github.com/org/repo/actions/workflows/links.yml)
Expand All @@ -122,19 +129,21 @@ It will look like this:

## Troubleshooting and common problems

See [lychee's Troubleshooting Guide](https://github.com/lycheeverse/lychee/blob/master/docs/TROUBLESHOOTING.md)
for solutions to common link-checking problems.
See [lychee's Troubleshooting Guide][troubleshooting] for solutions to common
link-checking problems.

## Performance

A full CI run to scan 576 links takes approximately 1 minute for the [analysis-tools-dev/static-analysis](https://github.com/analysis-tools-dev/static-analysis) repository.
A full CI run to scan 576 links takes approximately 1 minute for the
[analysis-tools-dev/static-analysis](https://github.com/analysis-tools-dev/static-analysis)
repository.

## Security and Updates

It is recommended to pin lychee-action to a fixed version [for security reasons](https://francoisbest.com/posts/2020/the-security-of-github-actions).
You can use dependabot to automatically keep your Github actions up-to-date.
This is a great way to pin lychee-action, while still receiving updates in the future.
It's a relatively easy thing to do.
It is recommended to pin lychee-action to a fixed version [for security
reasons][security]. You can use dependabot to automatically keep your Github
actions up-to-date. This is a great way to pin lychee-action, while still
receiving updates in the future. It's a relatively easy thing to do.

Create a file named `.github/dependabot.yml` with the following contents:

Expand All @@ -148,12 +157,13 @@ updates:
```

When you add or update the `dependabot.yml` file, this triggers an immediate check for version updates.
Please see [the documentation](https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file) for all configuration options.
Please see [the documentation][dependabot] for all configuration options.

### Security tip

For additional security when relying on automation to update actions you can pin the action to a SHA-256 rather than the semver version so as to avoid tag spoofing
Dependabot will still be able to automatically update this.
For additional security when relying on automation to update actions you can pin
the action to a SHA-256 rather than the semver version so as to avoid tag
spoofing Dependabot will still be able to automatically update this.

For example:

Expand All @@ -165,17 +175,24 @@ For example:

## 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
[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).

## 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://opensource.org/licenses/MIT)
- MIT license (LICENSE-MIT or https://choosealicense.com/licenses/mit/)

at your option.

[lychee]: https://github.com/lycheeverse/lychee
[lychee-args]: https://github.com/lycheeverse/lychee#commandline-parameters
[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
10 changes: 7 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,21 @@ inputs:
default: "--verbose --no-progress './**/*.md' './**/*.html'"
required: false
format:
description: "output format (e.g. json)"
description: "summary output format (e.g. json)"
default: "markdown"
required: false
output:
description: "output file"
description: "summary output file path"
default: "lychee/out.md"
required: false
fail:
description: "fail entire pipeline on error (exit code not 0)"
description: "fail entire pipeline on error (i.e. when lychee exit code is not 0)"
default: false
required: false
jobSummary:
description: "write Github job summary at the end of the job (written on Markdown output only)"
default: true
required: false
runs:
using: "docker"
image: "Dockerfile"
Expand Down
6 changes: 6 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ fi
cat "${LYCHEE_TMP}"
echo

if [ "${INPUT_FORMAT}" == "markdown" ]; then
if [ "${INPUT_JOBSUMMARY}" = true ]; then
cat "${LYCHEE_TMP}" > "${GITHUB_STEP_SUMMARY}"
fi
fi

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

Expand Down