-
Notifications
You must be signed in to change notification settings - Fork 151
139 lines (129 loc) · 5 KB
/
Copy pathlink-checks.yml
File metadata and controls
139 lines (129 loc) · 5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: Link Checks
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
UV_TORCH_BACKEND: "cpu"
jobs:
link-checks:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: (DOCS) Link Checker
id: lychee_docs
uses: lycheeverse/lychee-action@v2
with:
fail: false
args: --root-dir "$(pwd)/docs" --verbose --no-progress './docs/**/*.md'
- name: (DOCS) Find existing comment
if: github.event.pull_request.head.repo.full_name == github.repository
uses: peter-evans/find-comment@v4
id: find_docs_comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: "Link Check Results (DOCS)"
- name: (DOCS) Prepare failure comment
if: steps.lychee_docs.outputs.exit_code != '0'
run: |
{
echo "**Link Check Results (DOCS)**"
echo ""
cat ./lychee/out.md
echo ""
echo "---"
echo "*Last updated: ${{ github.event.pull_request.head.sha }}*"
} > ./lychee/docs_comment.md
- name: (DOCS) Create or update failure comment
if: >
steps.lychee_docs.outputs.exit_code != '0' &&
github.event.pull_request.head.repo.full_name == github.repository
uses: peter-evans/create-or-update-comment@v5
with:
comment-id: ${{ steps.find_docs_comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body-path: ./lychee/docs_comment.md
edit-mode: replace
- name: (DOCS) Mark previous failure as resolved
if: >
steps.lychee_docs.outputs.exit_code == '0' &&
steps.find_docs_comment.outputs.comment-id != '' &&
github.event.pull_request.head.repo.full_name == github.repository
uses: peter-evans/create-or-update-comment@v5
with:
comment-id: ${{ steps.find_docs_comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
~~**Link Check Results (DOCS)**~~
**All links are now valid** - this issue has been resolved.
---
*Marked as resolved: ${{ github.event.pull_request.head.sha }}*
edit-mode: replace
- name: (REPO) Link Checker
id: lychee_repo
uses: lycheeverse/lychee-action@v2
with:
fail: false
args: --root-dir "$(pwd)" --verbose --no-progress --exclude-path 'docs' './**/*.md'
- name: (REPO) Find existing comment
if: github.event.pull_request.head.repo.full_name == github.repository
uses: peter-evans/find-comment@v4
id: find_repo_comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: "Link Check Results (REPO)"
- name: (REPO) Prepare failure comment
if: steps.lychee_repo.outputs.exit_code != '0'
run: |
{
echo "**Link Check Results (REPO)**"
echo ""
cat ./lychee/out.md
echo ""
echo "---"
echo "*Last updated: ${{ github.event.pull_request.head.sha }}*"
} > ./lychee/repo_comment.md
- name: (REPO) Create or update failure comment
if: >
steps.lychee_repo.outputs.exit_code != '0' &&
github.event.pull_request.head.repo.full_name == github.repository
uses: peter-evans/create-or-update-comment@v5
with:
comment-id: ${{ steps.find_repo_comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body-path: ./lychee/repo_comment.md
edit-mode: replace
- name: (REPO) Mark previous failure as resolved
if: >
steps.lychee_repo.outputs.exit_code == '0' &&
steps.find_repo_comment.outputs.comment-id != '' &&
github.event.pull_request.head.repo.full_name == github.repository
uses: peter-evans/create-or-update-comment@v5
with:
comment-id: ${{ steps.find_repo_comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
~~**Link Check Results (REPO)**~~
**All links are now valid** - this issue has been resolved.
---
*Marked as resolved: ${{ github.event.pull_request.head.sha }}*
edit-mode: replace
- name: Fail on Issues
if: steps.lychee_docs.outputs.exit_code != '0' ||
steps.lychee_repo.outputs.exit_code != '0'
run: |
echo "Link Checker found issues. Please check the PR comment for details."
exit 1