-
Notifications
You must be signed in to change notification settings - Fork 497
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c79600d
commit 8c615cd
Showing
1 changed file
with
21 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,13 @@ name: Check Markdown links | |
on: | ||
push: | ||
paths: | ||
- '**/*.md' # Only run when markdown files change | ||
- '**/*.md' # Only run when markdown files change | ||
pull_request: | ||
branches: | ||
- main | ||
schedule: | ||
- cron: "0 0 * * 0" # Run weekly on Sundays | ||
workflow_dispatch: # Allows manual triggering | ||
- cron: '0 0 * * 0' # Run weekly on Sundays | ||
workflow_dispatch: # Allows manual triggering | ||
|
||
jobs: | ||
linkChecker: | ||
|
@@ -17,24 +20,31 @@ jobs: | |
- name: Link Checker | ||
uses: lycheeverse/[email protected] | ||
with: | ||
args: --verbose --no-progress './**/*.md' | ||
fail: true # Fail the action if broken links are found | ||
args: --verbose --no-progress --fail './**/*.md' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# Create an issue if the job fails (optional) | ||
- name: Create Issue If Failed | ||
if: failure() | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const title = '🔗 Broken links found in documentation'; | ||
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.'; | ||
github.rest.issues.create({ | ||
const existingIssues = await github.rest.issues.listForRepo({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
title: title, | ||
body: body, | ||
labels: ['documentation', 'broken-links'] | ||
labels: 'documentation,broken-links', | ||
}); | ||
const issueExists = existingIssues.data.some(issue => issue.title === title); | ||
if (!issueExists) { | ||
await github.rest.issues.create({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
title: title, | ||
body: body, | ||
labels: ['documentation', 'broken-links'] | ||
}); | ||
} |