feat: add workflow to check broken links#327
Conversation
Signed-off-by: Abhijeet Saharan <abhijeetsaharan2236@gmail.com>
✅ Deploy Preview for hiero-open-source ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Up to standards ✅🟢 Issues
|
📝 WalkthroughWalkthroughAdds a new GitHub Actions workflow (.github/workflows/check-broken-links.yml) that runs weekly or on manual dispatch, uses Lychee to scan Markdown for broken links, and conditionally creates or updates a GitHub issue (with a dry-run option). Error handling marks the workflow failed if issue management errors occur. ChangesBroken Link Checker Workflow
Sequence Diagram(s)sequenceDiagram
participant Runner as Runner (GitHub Actions)
participant Lychee as Lychee CLI
participant GitHubAPI as GitHub API
participant Repo as Repository (Markdown)
Note over Runner,Repo: Scheduled or manual trigger
Runner->>Repo: checkout code
Runner->>Lychee: run link scan on Markdown
Lychee-->>Runner: exit code + report
alt broken links found and not dry_run
Runner->>GitHubAPI: list open issues with labels
GitHubAPI-->>Runner: issues list
alt existing issue with title
Runner->>GitHubAPI: post comment to issue
GitHubAPI-->>Runner: comment created
else no existing issue
Runner->>GitHubAPI: create new labeled issue with body
GitHubAPI-->>Runner: issue created
end
else dry_run or no broken links
Runner-->>Runner: log results (no issue changes)
end
alt error during issue management
Runner->>Runner: mark workflow as failed
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
0c8ba51 to
748ca71
Compare
Signed-off-by: Abhijeet Saharan <abhijeetsaharan2236@gmail.com>
cc19b81 to
01a9f0c
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (2)
.github/workflows/check-broken-links.yml (2)
27-28: Consider aligningactions/checkoutversion withci.yml.This workflow uses
actions/checkoutv6.0.1, whileci.ymluses v6.0.2. Aligning versions across workflows reduces maintenance overhead and ensures consistent behavior.📦 Suggested version alignment
- name: Checkout repository - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/check-broken-links.yml around lines 27 - 28, Update the pinned actions/checkout reference in the workflow so it matches the version used in ci.yml: replace the current uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 with the same v6.0.2 tag/hash used in ci.yml to ensure consistent behavior across workflows (locate the uses: actions/checkout line to make the change).
18-20: Consider adding concurrency control.Unlike
ci.yml, this workflow lacks concurrency control. While unlikely for a weekly cron job, concurrent runs (e.g., manual trigger during scheduled run) could cause duplicate issue creation or conflicting updates.🔧 Add concurrency block
permissions: contents: read issues: write +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: cron-check-broken-links:🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/check-broken-links.yml around lines 18 - 20, Add a GitHub Actions concurrency block for the cron-check-broken-links job to prevent overlapping runs: in the workflow containing the cron-check-broken-links job, add a concurrency declaration (using a unique group name that includes the job name and the Git ref or workflow name) and enable cancel-in-progress so a new manual or scheduled run cancels the previous run; update the job block for cron-check-broken-links to reference that concurrency group.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.github/workflows/check-broken-links.yml:
- Around line 27-28: Update the pinned actions/checkout reference in the
workflow so it matches the version used in ci.yml: replace the current uses:
actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 with the same v6.0.2
tag/hash used in ci.yml to ensure consistent behavior across workflows (locate
the uses: actions/checkout line to make the change).
- Around line 18-20: Add a GitHub Actions concurrency block for the
cron-check-broken-links job to prevent overlapping runs: in the workflow
containing the cron-check-broken-links job, add a concurrency declaration (using
a unique group name that includes the job name and the Git ref or workflow name)
and enable cancel-in-progress so a new manual or scheduled run cancels the
previous run; update the job block for cron-check-broken-links to reference that
concurrency group.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f6e23bc0-18e7-4a60-aa54-c602422065b3
📒 Files selected for processing (1)
.github/workflows/check-broken-links.yml
MonaaEid
left a comment
There was a problem hiding this comment.
Hi @Abhijeet2409, I suggest creating a separate file for the script, for example: scripts/check-broken-links.js also, test this on your fork to see what the layout of the created issue looks like
exploreriii
left a comment
There was a problem hiding this comment.
Follows the python one very nicely with a key time adjustment, and well tested!
Thank you very much
|
Hey @MonaaEid, appreciate the suggestion. Since the goal was to import the workflow with minimal adjustments and the PR has already been approved, should I still go ahead and refactor this into a separate script, or keep it as is for now? |
|
No need to refactor this atm, nice work @Abhijeet2409 |
|
Is this ready for merge? |
danielmarv
left a comment
There was a problem hiding this comment.
LGTM!
Thanks @Abhijeet2409
|
cc @hiero-ledger/github-maintainers |
Signed-off-by: Abhijeet <abhijeetsaharan2236@gmail.com>
0949095
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/check-broken-links.yml:
- Around line 40-103: Add a companion success-path step (run when
steps.lychee.outcome == 'success') that searches open issues with the same
targetLabels and issueTitle using github.rest.issues.listForRepo, finds the
matching issue (issues.find by title === issueTitle), and closes it by calling
github.rest.issues.update with issue_number and state: 'closed'; keep dry-run
handling consistent (check dryRun) and log actions, and reuse the existing
targetLabels and issueTitle identifiers so the same automated issue is closed
when a subsequent run passes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: bebbddd2-b1c6-46ab-a50c-f06e9e9b7c1e
📒 Files selected for processing (1)
.github/workflows/check-broken-links.yml
|
I’ve addressed the requested changes. Let me know if anything else needs to be updated. |
|
cc @rbarker-dev |
|
@hiero-ledger/github-maintainers , Could you please review this PR again? The changes have been addressed |
|
@hiero-ledger/github-maintainers |
|
@hiero-ledger/github-maintainers |
Description
This PR adds a working bot workflow adapted from the hiero-sdk-python repository.
Changes
Test
https://github.com/Abhijeet2409/hiero-website/actions/runs/23794499047/job/69338162107
Fixes #283
Summary by CodeRabbit