Skip to content

Commit 8c615cd

Browse files
minor fixes
1 parent c79600d commit 8c615cd

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

.github/workflows/main.yml renamed to .github/workflows/link-checker.yml

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ name: Check Markdown links
33
on:
44
push:
55
paths:
6-
- '**/*.md' # Only run when markdown files change
6+
- '**/*.md' # Only run when markdown files change
7+
pull_request:
8+
branches:
9+
- main
710
schedule:
8-
- cron: "0 0 * * 0" # Run weekly on Sundays
9-
workflow_dispatch: # Allows manual triggering
11+
- cron: '0 0 * * 0' # Run weekly on Sundays
12+
workflow_dispatch: # Allows manual triggering
1013

1114
jobs:
1215
linkChecker:
@@ -17,24 +20,31 @@ jobs:
1720
- name: Link Checker
1821
uses: lycheeverse/[email protected]
1922
with:
20-
args: --verbose --no-progress './**/*.md'
21-
fail: true # Fail the action if broken links are found
23+
args: --verbose --no-progress --fail './**/*.md'
2224
env:
2325
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2426

25-
# Create an issue if the job fails (optional)
2627
- name: Create Issue If Failed
2728
if: failure()
2829
uses: actions/github-script@v6
2930
with:
3031
script: |
3132
const title = '🔗 Broken links found in documentation';
3233
const body = 'The link checker found broken links in the documentation. Please check the [workflow run](${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}) for details.';
33-
34-
github.rest.issues.create({
34+
35+
const existingIssues = await github.rest.issues.listForRepo({
3536
owner: context.repo.owner,
3637
repo: context.repo.repo,
37-
title: title,
38-
body: body,
39-
labels: ['documentation', 'broken-links']
38+
labels: 'documentation,broken-links',
4039
});
40+
41+
const issueExists = existingIssues.data.some(issue => issue.title === title);
42+
if (!issueExists) {
43+
await github.rest.issues.create({
44+
owner: context.repo.owner,
45+
repo: context.repo.repo,
46+
title: title,
47+
body: body,
48+
labels: ['documentation', 'broken-links']
49+
});
50+
}

0 commit comments

Comments
 (0)