-
Notifications
You must be signed in to change notification settings - Fork 515
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
updated failed preview deploy #9884
base: develop
Are you sure you want to change the base?
Conversation
WalkthroughThis pull request modifies the GitHub Actions workflow file for managing deployment preview labels. The changes focus on refining the workflow's functionality, updating its name, expanding permissions, and improving the logic for handling deployment status labels. The workflow now provides more precise control over labeling deploy preview statuses, with enhanced conditional checks and more granular label management using GitHub API interactions. Changes
Possibly related PRs
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for care-ohc ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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.
Actionable comments posted: 3
🧹 Nitpick comments (2)
.github/workflows/label-deploy-failed.yml (2)
11-17
: Consider enhancing the conditional checks.While the current conditions are good, consider adding checks for:
- Comment author (should be from a trusted deployment service)
- PR state (should be open)
This would prevent unnecessary workflow runs and potential security issues.
if: | github.repository == 'ohcnetwork/care_fe' && github.event.issue.pull_request && - contains(github.event.comment.body, 'Deploy Preview') + contains(github.event.comment.body, 'Deploy Preview') && + github.event.issue.state == 'open' && + contains(fromJson('["netlify[bot]", "vercel[bot]"]'), github.event.comment.user.login)
39-44
: Replace curl command with github-script.Using curl for GitHub API calls is less maintainable. Consider using the github-script action instead.
- name: Remove Deploy-Failed label if deploy is successful if: steps.check-status.outputs.isDeploySuccessful == 'true' - run: | - curl -X DELETE \ - -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ - https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/labels/Deploy-Failed + uses: actions/github-script@v7 + with: + script: | + const { owner, repo } = context.repo; + const issue_number = context.issue.number; + + try { + await github.rest.issues.removeLabel({ + owner, + repo, + issue_number, + name: 'Deploy-Failed' + }); + } catch (error) { + if (error.status !== 404) throw error; + // Ignore 404 errors when label doesn't exist + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/label-deploy-failed.yml
(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/label-deploy-failed.yml
20-20: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
24-24: the runner of "actions/github-script@v6" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: OSSAR-Scan
- GitHub Check: cypress-run (1)
- GitHub Check: Cloudflare Pages: care-fe
🔇 Additional comments (2)
.github/workflows/label-deploy-failed.yml (2)
1-4
: LGTM! Appropriate permissions and naming.The workflow name better reflects its purpose, and the added
issues
write permission is necessary for label management.
6-8
: LGTM! Appropriate event triggers.The workflow correctly triggers on both new and edited comments to catch all deploy preview status updates.
- name: Check out the repository | ||
uses: actions/checkout@v3 | ||
|
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.
🛠️ Refactor suggestion
Update checkout action version.
The actions/checkout
action has a newer version available.
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
- name: Check out the repository | |
uses: actions/checkout@v3 | |
- name: Check out the repository | |
uses: actions/checkout@v4 | |
🧰 Tools
🪛 actionlint (1.7.4)
20-20: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
- name: Check deploy status | ||
id: check-status | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
github.rest.issues.addLabels({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
labels: ["Deploy-Failed"] | ||
}) | ||
const comment = context.payload.comment.body; | ||
return { | ||
isDeployFailed: /deploy preview.*failed|failed to deploy/i.test(comment), | ||
isDeploySuccessful: /deploy preview.*ready|successfully deployed/i.test(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.
🛠️ Refactor suggestion
Improve deploy status check robustness.
The current implementation has several potential improvements:
- The github-script action should be updated to v7
- The output needs proper JSON stringification
- The regex patterns could be more precise
- name: Check deploy status
id: check-status
- uses: actions/github-script@v6
+ uses: actions/github-script@v7
with:
script: |
const comment = context.payload.comment.body;
- return {
+ core.setOutput('result', JSON.stringify({
isDeployFailed: /deploy preview.*failed|failed to deploy/i.test(comment),
isDeploySuccessful: /deploy preview.*ready|successfully deployed/i.test(comment),
- };
+ }));
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
- name: Check deploy status | |
id: check-status | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
github.rest.issues.addLabels({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
labels: ["Deploy-Failed"] | |
}) | |
const comment = context.payload.comment.body; | |
return { | |
isDeployFailed: /deploy preview.*failed|failed to deploy/i.test(comment), | |
isDeploySuccessful: /deploy preview.*ready|successfully deployed/i.test(comment), | |
}; | |
- name: Check deploy status | |
id: check-status | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const comment = context.payload.comment.body; | |
core.setOutput('result', JSON.stringify({ | |
isDeployFailed: /deploy preview.*failed|failed to deploy/i.test(comment), | |
isDeploySuccessful: /deploy preview.*ready|successfully deployed/i.test(comment), | |
})); |
🧰 Tools
🪛 actionlint (1.7.4)
24-24: the runner of "actions/github-script@v6" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
- name: Add Deploy-Failed label if needed | ||
if: steps.check-status.outputs.isDeployFailed == 'true' | ||
uses: actions/labeler@v5 | ||
with: | ||
script: | | ||
github.rest.issues.removeLabel({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
labels: ["Deploy-Failed"] | ||
}) | ||
repo-token: "${{ secrets.GITHUB_TOKEN }}" | ||
|
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.
💡 Codebase verification
The review comment is correct - actions/labeler@v5 is the wrong action for this use case
The actions/labeler@v5
action is designed for pattern-based PR labeling and requires a labeler.yml configuration file. For adding a single "Deploy-Failed" label, you should use a simpler approach like actions/github-script
or a dedicated label action similar to how the merge conflict workflow uses a specialized action.
Example fix:
- name: Add Deploy-Failed label if needed
if: steps.check-status.outputs.isDeployFailed == 'true'
uses: actions/github-script@v6
with:
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.name,
labels: ['Deploy-Failed']
})
🔗 Analysis chain
Verify labeler configuration.
The actions/labeler@v5
usage appears incomplete. It requires a configuration file to specify label rules.
Please ensure you have a .github/labeler.yml
file with appropriate rules. Run this script to check:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check for labeler configuration
if [ -f ".github/labeler.yml" ]; then
cat ".github/labeler.yml"
else
echo "Warning: labeler.yml not found"
fi
Length of output: 103
Script:
#!/bin/bash
# Search for any label-related configuration files
fd -e yml -e yaml . .github/ | grep -i label
# Search for label-related actions in workflows
rg -l "label" .github/workflows/
Length of output: 534
Script:
#!/bin/bash
# Check implementation in other label workflows
for file in .github/workflows/label-*.yml .github/workflows/auto-testing-label.yml; do
echo "=== $file ==="
rg "uses:.*label" "$file" -A 2
done
Length of output: 1235
CARE Run #4245
Run Properties:
|
Project |
CARE
|
Branch Review |
vysakh/deploy-tag
|
Run status |
Failed #4245
|
Run duration | 02m 20s |
Commit |
42b2db0d14: updated failed preview deploy
|
Committer | Vysakh Premkumar |
View all properties for this run ↗︎ |
Test results | |
---|---|
Failures |
2
|
Flaky |
0
|
Pending |
0
|
Skipped |
1
|
Passing |
3
|
View all changes introduced in this branch ↗︎ |
Tests for review
facility_spec/facility_creation.cy.ts • 1 failed test
Test | Artifacts | |
---|---|---|
Facility Management > Create a new facility using the admin role |
Test Replay
Screenshots
|
patient_spec/patient_search.cy.ts • 1 failed test
Test | Artifacts | |
---|---|---|
Patient Search > search patient with phone number and verifies details |
Test Replay
Screenshots
|
Updated
label-deploy-failed.yml
to use actions/labeler@v5 GitHub Action instead of custom script for la belling and fixed the broken delete label function.Summary by CodeRabbit