Skip to content

Commit 651fb63

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

File tree

3 files changed

+88
-1
lines changed

3 files changed

+88
-1
lines changed

.github/workflows/links.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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 github-script to comment on PRs
16+
steps:
17+
- uses: actions/checkout@v5
18+
19+
- name: Link Checker
20+
id: lychee
21+
uses: lycheeverse/lychee-action@v2
22+
with:
23+
args: . --exclude-path "tests"
24+
fail: false
25+
26+
# - name: Create or Update PR Comment
27+
# if: steps.lychee.outputs.exit_code != 0 && github.event_name == 'pull_request'
28+
# uses: actions/github-script@v8
29+
# with:
30+
# script: |
31+
# const fs = require('fs');
32+
# const commentMarker = '<!-- link-checker-report -->';
33+
34+
# // Read the report file if it exists, otherwise use a fallback message
35+
# let body;
36+
# if (fs.existsSync('./lychee/out.md')) {
37+
# body = fs.readFileSync('./lychee/out.md', 'utf8');
38+
# } else {
39+
# body = '## 🔗 Link Checker Report\n\nThe link checker found broken links in this pull request. Please check the workflow logs for details.';
40+
# }
41+
42+
# // Add the marker to identify this comment
43+
# body = commentMarker + '\n\n' + body;
44+
45+
# // Get existing comments on the PR
46+
# const { data: comments } = await github.rest.issues.listComments({
47+
# owner: context.repo.owner,
48+
# repo: context.repo.repo,
49+
# issue_number: context.issue.number,
50+
# });
51+
52+
# // Find existing comment with our marker
53+
# const existingComment = comments.find(comment =>
54+
# comment.user.type === 'Bot' &&
55+
# comment.body.includes(commentMarker)
56+
# );
57+
58+
# if (existingComment) {
59+
# // Update existing comment
60+
# await github.rest.issues.updateComment({
61+
# owner: context.repo.owner,
62+
# repo: context.repo.repo,
63+
# comment_id: existingComment.id,
64+
# body: body,
65+
# });
66+
# } else {
67+
# // Create new comment
68+
# await github.rest.issues.createComment({
69+
# owner: context.repo.owner,
70+
# repo: context.repo.repo,
71+
# issue_number: context.issue.number,
72+
# body: body,
73+
# });
74+
# }
75+
76+
# - name: Create Issue From File
77+
# if: steps.lychee.outputs.exit_code != 0 && github.event_name == 'schedule'
78+
# uses: peter-evans/create-issue-from-file@v5
79+
# with:
80+
# title: Link Checker Report
81+
# content-filepath: ./lychee/out.md
82+
# labels: 'type: documentation'

.github/workflows/pythonpackage.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
name: Python package
22

3-
on: [workflow_dispatch, pull_request]
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
paths:
7+
- "!docs/**"
48

59
jobs:
610
python-check:

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)