File tree Expand file tree Collapse file tree
src/content/docs/github_action_recipes Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -68,6 +68,10 @@ export default defineConfig({
6868 {
6969 label : "GitHub Action Recipes" ,
7070 items : [
71+ {
72+ label : "Check Links in Repository" ,
73+ link : "/github_action_recipes/check-repository" ,
74+ } ,
7175 {
7276 label : "Check Links in Pull Requests" ,
7377 link : "/github_action_recipes/pull-requests" ,
Original file line number Diff line number Diff line change 1+ ---
2+ title : Check Links in Repository
3+ ---
4+
5+ This recipe demonstrates how to set up an automated workflow that will check all repository links once per day and create an issue in case of errors.
6+
7+ ## Usage
8+
9+ Add this workflow to ` .github/workflows/links.yml ` in your repository
10+
11+ ## Workflow
12+
13+ ``` yaml
14+ name : Links
15+
16+ on :
17+ repository_dispatch :
18+ workflow_dispatch :
19+ schedule :
20+ - cron : " 00 18 * * *"
21+
22+ jobs :
23+ linkChecker :
24+ runs-on : ubuntu-latest
25+ permissions :
26+ issues : write # required for peter-evans/create-issue-from-file
27+ steps :
28+ - uses : actions/checkout@v4
29+
30+ - name : Link Checker
31+ id : lychee
32+ uses : lycheeverse/lychee-action@v2
33+ with :
34+ fail : false
35+
36+ - name : Create Issue From File
37+ if : steps.lychee.outputs.exit_code != 0
38+ uses : peter-evans/create-issue-from-file@v5
39+ with :
40+ title : Link Checker Report
41+ content-filepath : ./lychee/out.md
42+ labels : report, automated issue
43+ ` ` `
44+
45+ ## Explanation
46+
47+ The workflow is triggered in three scenarios:
48+ 1. Manual trigger via ` workflow_dispatch`
49+ 2. Repository dispatch events
50+ 3. Automated schedule (runs daily at 18:00 UTC)
51+
52+ The workflow executes the following steps :
53+ 1. Checks out the repository using `actions/checkout@v4`
54+ 2. Runs the Lychee link checker (`lycheeverse/lychee-action@v2`) with `fail : false` to prevent workflow failure
55+ 3. If any broken links are detected (exit code != 0), creates a new GitHub issue using `peter-evans/create-issue-from-file@v5`
56+ - The issue contains the detailed report from `./lychee/out.md`
57+ - Issues are labeled with "report" and "automated issue"
58+
59+ The workflow requires write permissions for issues to create automated reports when broken links are found.
You can’t perform that action at this time.
0 commit comments