Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vrushankportkey committed Dec 9, 2024
1 parent c79600d commit 8c615cd
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions .github/workflows/main.yml → .github/workflows/link-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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']
});
}

0 comments on commit 8c615cd

Please sign in to comment.