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

feat: add broken link check #34

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
40 changes: 40 additions & 0 deletions .github/workflows/link-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: links when pr

on:
pull_request:
branches: [ main ]
paths:
- '**.md'
- '.lycheeignore'

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

- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: "latest"

- name: Build
run: hugo --minify

- name: Link Checker
uses: lycheeverse/[email protected]
with:
fail: true
# For parameter description, see https://github.com/lycheeverse/lychee#commandline-parameters
# -E, --exclude-all-private Exclude all private IPs from checking.
# -i, --insecure Proceed for server connections considered insecure (invalid TLS)
# -n, --no-progress Do not show progress bar.
# -t, --timeout <timeout> Website timeout in seconds from connect to response finished [default:20]
# --max-concurrency <max-concurrency> Maximum number of concurrent network requests [default: 128]
# -a --accept <accept> Comma-separated list of accepted status codes for valid links

# ./site the MkDocs site directory to check
# ./*.md all markdown files in the root directory
args: -E -i -n -t 45 --max-concurrency 64 -a 429,401 -- 'public' '*.md'
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
51 changes: 51 additions & 0 deletions .github/workflows/link.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: links

on:
repository_dispatch:
workflow_dispatch:
schedule:
- cron: "30 8 * * *"

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

- name: Download Exclude Path
run: |
curl https://raw.githubusercontent.com/gocn/How-To-Code-in-Go/main/.lycheeignore --output .lycheeignore

- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: "latest"

- name: Build
run: hugo --minify

- name: Check Links
uses: lycheeverse/[email protected]
with:
# For parameter description, see https://github.com/lycheeverse/lychee#commandline-parameters
# -E, --exclude-all-private Exclude all private IPs from checking.
# -v, --verbose Verbose program output
# -i, --insecure Proceed for server connections considered insecure (invalid TLS)
# -n, --no-progress Do not show progress bar.
# -t, --timeout <timeout> Website timeout in seconds from connect to response finished [default:20]
# --max-concurrency <max-concurrency> Maximum number of concurrent network requests [default: 128]
# -a --accept <accept> Comma-separated list of accepted status codes for valid links

# ./site the MkDocs site directory to check
# ./*.md all markdown files in the root directory
args: -E -v -i -n -t 45 --max-concurrency 64 -a 429,401 -- 'public' '*.md'
output: out.md
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Create Issue From File
uses: peter-evans/create-issue-from-file@v3
with:
title: Broken Link Detected
content-filepath: out.md
# assignees: aFlyBird0
1 change: 1 addition & 0 deletions .lycheeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

贡献者(按昵称首字母排序):

> [astaxie](https://github.com/astaxie) | [Cluas](https://github.com/Cluas) | [cvley](https://github.com/cvley) | [Fivezh](https://github.com/fivezh) | [iddunk](https://github.com/iddunk) | [lsj1342](https://github.com/lsj1342) | [watermelon](https://github.com/watermelo) | [小超人](https://github.com/ddikvy) | [Xiaomin Zheng](https://github.com/zxmfke) | [Yu Zhang](https://github.com/pseudoyu) | [朱亚光](https://github.com/zhuyaguang)
> [astaxie](https://github.com/astaxie) | [Cluas](https://github.com/Cluas) | [cvley](https://github.com/cvley) | [Fivezh](https://github.com/fivezh) | [iddunk](https://github.com/iddunk) | [lsj1342](https://github.com/lsj1342) | [watermelon](https://github.com/watermelo) | [小超人](https://github.com/focozz) | [Xiaomin Zheng](https://github.com/zxmfke) | [Yu Zhang](https://github.com/pseudoyu) | [朱亚光](https://github.com/zhuyaguang)

安装完 `hugo` 之后,需要先同步主题文件

Expand Down Expand Up @@ -137,7 +137,7 @@ The articles in 《How-To-Code-in-Go》 are licensed under a [Creative Commons A
</a>
</td>
<td align="center">
<a href="https://github.com/dijkvy">
<a href="https://github.com/focozz">
<img src="https://avatars.githubusercontent.com/u/67250607?v=4" width="100;" alt="dijkvy"/>
<br />
<sub><b>小超人</b></sub>
Expand All @@ -158,4 +158,4 @@ The articles in 《How-To-Code-in-Go》 are licensed under a [Creative Commons A
</a>
</td></tr>
</table>
<!-- readme: collaborators,contributors -end -->
<!-- readme: collaborators,contributors -end -->
4 changes: 2 additions & 2 deletions content/zh/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type: docs

贡献者(按昵称首字母排序):

> [astaxie](https://github.com/astaxie) | [Cluas](https://github.com/Cluas) | [cvley](https://github.com/cvley) | [Fivezh](https://github.com/fivezh) | [iddunk](https://github.com/iddunk) | [lsj1342](https://github.com/lsj1342) | [watermelon](https://github.com/watermelo) | [小超人](https://github.com/ddikvy) | [Xiaomin Zheng](https://github.com/zxmfke) | [Yu Zhang](https://github.com/pseudoyu) | [朱亚光](https://github.com/zhuyaguang)
> [astaxie](https://github.com/astaxie) | [Cluas](https://github.com/Cluas) | [cvley](https://github.com/cvley) | [Fivezh](https://github.com/fivezh) | [iddunk](https://github.com/iddunk) | [lsj1342](https://github.com/lsj1342) | [watermelon](https://github.com/watermelo) | [小超人](https://github.com/focozz) | [Xiaomin Zheng](https://github.com/zxmfke) | [Yu Zhang](https://github.com/pseudoyu) | [朱亚光](https://github.com/zhuyaguang)

安装完 `hugo` 之后,需要先同步主题文件

Expand Down Expand Up @@ -70,4 +70,4 @@ hugo server

## 授权

The articles in 《How-To-Code-in-Go》 are licensed under a [Creative Commons Attribution-ShareAlike 4.0 International License](http://creativecommons.org/licenses/by-sa/4.0/).
The articles in 《How-To-Code-in-Go》 are licensed under a [Creative Commons Attribution-ShareAlike 4.0 International License](http://creativecommons.org/licenses/by-sa/4.0/).
4 changes: 2 additions & 2 deletions static/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

贡献者(按昵称首字母排序):

> [astaxie](https://github.com/astaxie) | [Cluas](https://github.com/Cluas) | [cvley](https://github.com/cvley) | [Fivezh](https://github.com/fivezh) | [iddunk](https://github.com/iddunk) | [lsj1342](https://github.com/lsj1342) | [watermelon](https://github.com/watermelo) | [小超人](https://github.com/ddikvy) | [Xiaomin Zheng](https://github.com/zxmfke) | [Yu Zhang](https://github.com/pseudoyu) | [朱亚光](https://github.com/zhuyaguang)
> [astaxie](https://github.com/astaxie) | [Cluas](https://github.com/Cluas) | [cvley](https://github.com/cvley) | [Fivezh](https://github.com/fivezh) | [iddunk](https://github.com/iddunk) | [lsj1342](https://github.com/lsj1342) | [watermelon](https://github.com/watermelo) | [小超人](https://github.com/focozz) | [Xiaomin Zheng](https://github.com/zxmfke) | [Yu Zhang](https://github.com/pseudoyu) | [朱亚光](https://github.com/zhuyaguang)

安装完 `hugo` 之后,需要先同步主题文件

Expand Down Expand Up @@ -65,4 +65,4 @@ hugo server

## 授权

The articles in 《How-To-Code-in-Go》 are licensed under a [Creative Commons Attribution-ShareAlike 4.0 International License](http://creativecommons.org/licenses/by-sa/4.0/).
The articles in 《How-To-Code-in-Go》 are licensed under a [Creative Commons Attribution-ShareAlike 4.0 International License](http://creativecommons.org/licenses/by-sa/4.0/).