Skip to content

Commit ec3be4b

Browse files
committed
ci: add link checker
1 parent e241812 commit ec3be4b

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

.github/workflows/links.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Links
2+
3+
on:
4+
repository_dispatch:
5+
workflow_dispatch:
6+
pull_request:
7+
schedule:
8+
- cron: "00 18 * * *"
9+
10+
jobs:
11+
linkChecker:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
issues: write # required for peter-evans/create-issue-from-file
15+
pull-requests: write # required for peter-evans/create-or-update-comment
16+
steps:
17+
- uses: actions/checkout@v5
18+
19+
- name: Link Checker
20+
id: lychee
21+
uses: lycheeverse/lychee-action@v2
22+
with:
23+
fail: false
24+
25+
- name: Prepare PR Comment
26+
if: steps.lychee.outputs.exit_code != 0 && github.event_name == 'pull_request'
27+
run: |
28+
if [ -f ./lychee/out.md ]; then
29+
cp ./lychee/out.md ./pr-comment.md
30+
else
31+
echo "## 🔗 Link Checker Report" > ./pr-comment.md
32+
echo "" >> ./pr-comment.md
33+
echo "The link checker found broken links in this pull request. Please check the workflow logs for details." >> ./pr-comment.md
34+
fi
35+
36+
- name: Create or Update PR Comment
37+
if: steps.lychee.outputs.exit_code != 0 && github.event_name == 'pull_request'
38+
uses: peter-evans/create-or-update-comment@v4
39+
with:
40+
issue-number: ${{ github.event.pull_request.number }}
41+
body-path: ./pr-comment.md
42+
edit-mode: replace
43+
comment-id: link-checker-report
44+
45+
- name: Create Issue From File
46+
if: steps.lychee.outputs.exit_code != 0 && github.event_name == 'schedule'
47+
uses: peter-evans/create-issue-from-file@v5
48+
with:
49+
title: Link Checker Report
50+
content-filepath: ./lychee/out.md
51+
labels: 'type: documentation'

docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/commitizen-tools/commitizen/pythonpackage.yml?label=python%20package&logo=github&logoColor=white&style=flat-square)](https://github.com/commitizen-tools/commitizen/actions)
2+
[![Check Links](https://github.com/commitizen-tools/commitizen/actions/workflows/links.yml/badge.svg)](https://github.com/commitizen-tools/commitizen/actions/workflows/links.yml)
23
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg?style=flat-square)](https://conventionalcommits.org)
34
[![PyPI Package latest release](https://img.shields.io/pypi/v/commitizen.svg?style=flat-square)](https://pypi.org/project/commitizen/)
45
[![PyPI Package download count (per month)](https://img.shields.io/pypi/dm/commitizen?style=flat-square)](https://pypi.org/project/commitizen/)

0 commit comments

Comments
 (0)