-
Notifications
You must be signed in to change notification settings - Fork 40
Add PR comment updating to link checker workflow #2054
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This adds functionality to automatically comment on PRs with link checker results when the Mintlify deployment completes. The comment will be updated on subsequent runs and clearly indicates whether all links are valid or if issues were found.
- Fix JavaScript syntax error when exit_code is empty - Handle both pull_request and deployment_status events properly - Use safe string interpolation for exit code - Fallback to docs.wandb.ai when no deployment URL available
| if (context.eventName === 'deployment_status') { | ||
| const sha = context.payload.deployment?.sha; | ||
| if (!sha) { | ||
| core.warning('No deployment SHA found'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the deployment SHA the same has the GitHub PR SHA? If yay, you can use the baked in environment variable
echo "The commit SHA is: ${{ github.sha }}"If not, disregard this comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the SHA that the Mintlify preview is built from, from Mintlify's POV. If Mintlify stopped building previews for subsequent hashes for some reason, this is how we would get visibility into that.
Change push trigger to only run on main branch. This prevents duplicate workflow runs when pushing to PR branches (which triggers both push and pull_request events). Now: - PRs: validated via pull_request trigger - Main branch: validated via push trigger - Manual: workflow_dispatch still available
| uses: actions/github-script@v8 | ||
| with: | ||
| script: | | ||
| // For pull_request events, get PR number directly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another idea, not sure if it's relevant, but depending on the event this is triggered for, you can automatically get access to PR #'s , etc.
E.g. for pull_request events, we get the PR number:
echo "The PR number is ${{ github.event.number }}"There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are, from within the context.payload struct, see line 97. I don't mind David's approach of saving it to a local variable.
| branches: | ||
| - '**' | ||
| - '!main' | ||
| - main |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This just prevents a duplicate validate-mdx trigger on every PR push. This branch definition means that the check will run on direct commits to main (outside the scope of a PR.
Description
Recent updates added PR commenting to the link checker, but the initial comment would not be updated by subsequent runs. This fixes that.
Testing
mint dev)mint broken-links)