Skip to content
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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open

updated failed preview deploy #9884

wants to merge 1 commit into from

Conversation

tellmeY18
Copy link
Member

@tellmeY18 tellmeY18 commented Jan 10, 2025

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

  • Chores
    • Updated GitHub Actions workflow for managing deployment preview labels
    • Improved workflow clarity and functionality
    • Enhanced label management for deployment statuses
    • Refined job and workflow naming conventions

@tellmeY18 tellmeY18 requested a review from a team as a code owner January 10, 2025 14:46
Copy link
Contributor

coderabbitai bot commented Jan 10, 2025

Walkthrough

This 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

File Change Summary
.github/workflows/label-deploy-failed.yml - Renamed workflow from "Auto label failed preview deploys" to "Auto label deploy preview status"
- Updated job name from "auto-label-deploy-failed" to "manage-deploy-labels"
- Added repository checkout step
- Refined conditional logic for job execution
- Implemented new deploy status checking script
- Modified label management using actions/labeler@v5
- Added step to remove "Deploy-Failed" label on successful deployment

Possibly related PRs

Suggested reviewers

  • shivankacker

Poem

🐰 Deployment labels dance and sway,
A GitHub workflow's clever play,
Checkouts and scripts in harmony,
Labels added with precision's glee,
CodeRabbit's magic on display! 🚀


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented Jan 10, 2025

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 42b2db0
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/678132c833be1a00087ca4e4
😎 Deploy Preview https://deploy-preview-9884--care-ohc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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:

  1. Comment author (should be from a trusted deployment service)
  2. 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

📥 Commits

Reviewing files that changed from the base of the PR and between 86eba9b and 42b2db0.

📒 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.

Comment on lines +19 to +21
- name: Check out the repository
uses: actions/checkout@v3

Copy link
Contributor

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.

Suggested change
- 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)

Comment on lines +22 to +31
- 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),
};
Copy link
Contributor

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:

  1. The github-script action should be updated to v7
  2. The output needs proper JSON stringification
  3. 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.

Suggested change
- 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)

Comment on lines +33 to +38
- 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 }}"

Copy link
Contributor

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

@github-actions github-actions bot added the Deploy-Failed Deplyment is not showing preview label Jan 10, 2025
Copy link

cypress bot commented Jan 10, 2025

CARE    Run #4245

Run Properties:  status check failed Failed #4245  •  git commit 42b2db0d14: updated failed preview deploy
Project CARE
Branch Review vysakh/deploy-tag
Run status status check failed Failed #4245
Run duration 02m 20s
Commit git commit 42b2db0d14: updated failed preview deploy
Committer Vysakh Premkumar
View all properties for this run ↗︎

Test results
Tests that failed  Failures 2
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 1
Tests that passed  Passing 3
View all changes introduced in this branch ↗︎

Tests for review

Failed  facility_spec/facility_creation.cy.ts • 1 failed test

View Output

Test Artifacts
Facility Management > Create a new facility using the admin role Test Replay Screenshots
Failed  patient_spec/patient_search.cy.ts • 1 failed test

View Output

Test Artifacts
Patient Search > search patient with phone number and verifies details Test Replay Screenshots

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deploy-Failed Deplyment is not showing preview
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant