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

Updates for Github Actions for Staging and Production #619

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

justin808
Copy link
Member

@justin808 justin808 commented Jan 27, 2025

This change is Reviewable

Summary by CodeRabbit

  • Workflow Updates
    • Updated GitHub Actions workflows to use staging-specific secrets.
    • Replaced CPLN_TOKEN and CPLN_ORG with CPLN_TOKEN_STAGING and CPLN_ORG_STAGING.
    • Modified environment variable configurations across multiple workflow files.
    • Enhanced help command output to reflect new staging environment variables.
    • Removed the workflow for deploying the main branch to the control plane staging environment.
    • Improved clarity and maintainability of deployment workflows with updated job names and conditions.

Copy link

coderabbitai bot commented Jan 27, 2025

Warning

Rate limit exceeded

@justin808 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 58 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 1601222 and af6bfc9.

📒 Files selected for processing (3)
  • .controlplane/controlplane.yml (1 hunks)
  • .github/actions/setup-environment/action.yml (1 hunks)
  • .github/workflows/deploy-to-control-plane.yml (4 hunks)

Walkthrough

The pull request focuses on updating GitHub Actions workflow files to use new staging-specific secrets. Across multiple workflow files (delete-review-app, deploy-to-control-plane, help-command, and promote-staging-to-production), the changes consistently replace CPLN_TOKEN and CPLN_ORG with CPLN_TOKEN_STAGING and CPLN_ORG_STAGING. Additional modifications include enhancements to workflow triggers, job names, and the introduction of new environment variables, indicating a refinement of secret management for staging environments.

Changes

File Change Summary
.github/workflows/delete-review-app.yml Updated secret references from CPLN_TOKEN to CPLN_TOKEN_STAGING and CPLN_ORG to CPLN_ORG_STAGING.
.github/workflows/deploy-to-control-plane.yml Replaced environment variables and secret validation to use staging-specific secrets; refactored console link generation and PR number handling; updated workflow name and job name.
.github/workflows/help-command.yml Updated help message to reflect new staging secret variable names.
.github/workflows/promote-staging-to-production.yml Changed CPLN_TOKEN to use CPLN_TOKEN_STAGING.
.github/workflows/deploy-to-control-plane-staging.yml Removed workflow for deploying the main branch to the control plane staging environment.

Possibly related PRs

Poem

🐰 Secrets dance, a staging ballet
Old tokens fade, new paths light the way
Workflows whisper their refined refrain
Staging secrets, no longer plain
A rabbit's code, precise and bright! 🔑


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.

@justin808 justin808 force-pushed the justin808-testing-2025-01-04 branch from 7c34a48 to c31e3d8 Compare January 27, 2025 02:32
@justin808
Copy link
Member Author

/deploy-review-app

Copy link

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

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments.

Actionable comments posted: 1

🔭 Outside diff range comments (2)
.github/workflows/promote-staging-to-production.yml (1)

Line range hint 17-28: Ensure consistent use of staging environment variables.

The workflow uses CPLN_TOKEN_STAGING but still references CPLN_ORG instead of CPLN_ORG_STAGING. This inconsistency could lead to mixing staging and production environments.

Apply this diff to maintain consistency:

    env:
-     CPLN_ORG: ${{ secrets.CPLN_ORG }}
+     CPLN_ORG: ${{ secrets.CPLN_ORG_STAGING }}
      UPSTREAM_TOKEN: ${{ secrets.STAGING_TOKEN }}
🧰 Tools
🪛 yamllint (1.35.1)

[error] 29-29: trailing spaces

(trailing-spaces)

.github/workflows/delete-review-app.yml (1)

Line range hint 13-17: Fix environment variable and validation mismatch.

There's an inconsistency between the environment variables and the validation step:

  • Environment uses CPLN_ORG but validation checks for CPLN_ORG_STAGING
  • This mismatch will cause the validation to fail even when CPLN_ORG is set correctly

Apply this diff to fix the inconsistency:

  env:
-   CPLN_ORG: ${{ secrets.CPLN_ORG }}
+   CPLN_ORG: ${{ secrets.CPLN_ORG_STAGING }}
    CPLN_TOKEN: ${{ secrets.CPLN_TOKEN_STAGING }}

Also applies to: 37-37

🛑 Comments failed to post (1)
.github/workflows/deploy-to-control-plane.yml (1)

17-19: ⚠️ Potential issue

Fix environment variable and validation mismatch.

Similar to delete-review-app.yml, there's an inconsistency between the environment variables and the validation step:

  • Environment uses CPLN_ORG but validation checks for CPLN_ORG_STAGING
  • This mismatch will cause the validation to fail even when CPLN_ORG is set correctly

Apply this diff to fix the inconsistency:

  env:
-   CPLN_ORG: ${{ secrets.CPLN_ORG }}
+   CPLN_ORG: ${{ secrets.CPLN_ORG_STAGING }}
    CPLN_TOKEN: ${{ secrets.CPLN_TOKEN_STAGING }}

Also applies to: 56-56

Copy link

github-actions bot commented Jan 27, 2025

🚀 Deploying to Control Plane...

⏳ Waiting for deployment to be ready...

📝 View Deploy Logs

🎮 Control Plane Console

Copy link

github-actions bot commented Jan 27, 2025

✅ Deployment successful!

🌐 Review app is ready at:

📝 View App Logs

Control Plane Console for Review App with PR #619

Copy link

@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: 0

🧹 Nitpick comments (1)
.github/workflows/deploy-to-control-plane.yml (1)

167-170: Remove trailing spaces in conditional statements

There are trailing spaces at the end of these lines that should be removed for consistency.

-          (github.event_name == 'issue_comment' && 
-           github.event.issue.pull_request && 
-           github.event.comment.body == '/deploy-review-app') || 
+          (github.event_name == 'issue_comment' &&
+           github.event.issue.pull_request &&
+           github.event.comment.body == '/deploy-review-app') ||
🧰 Tools
🪛 yamllint (1.35.1)

[error] 167-167: trailing spaces

(trailing-spaces)


[error] 168-168: trailing spaces

(trailing-spaces)


[error] 169-169: trailing spaces

(trailing-spaces)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c31e3d8 and a4b0353.

📒 Files selected for processing (1)
  • .github/workflows/deploy-to-control-plane.yml (6 hunks)
🧰 Additional context used
🪛 yamllint (1.35.1)
.github/workflows/deploy-to-control-plane.yml

[error] 161-161: trailing spaces

(trailing-spaces)


[error] 167-167: trailing spaces

(trailing-spaces)


[error] 168-168: trailing spaces

(trailing-spaces)


[error] 169-169: trailing spaces

(trailing-spaces)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test (22.x, 3.3.4)
🔇 Additional comments (3)
.github/workflows/deploy-to-control-plane.yml (3)

161-163: LGTM! Clear and secure console link generation

The console link generation is now more straightforward and properly uses environment variables.

🧰 Tools
🪛 yamllint (1.35.1)

[error] 161-161: trailing spaces

(trailing-spaces)


242-242: LGTM! Proper step outputs usage

Good improvement in using step outputs for the review app URL by adding an ID to the deploy step.

Also applies to: 261-261


19-20: Verify staging secrets configuration

The workflow now uses staging-specific secrets. Please ensure these secrets are properly configured in the repository settings.

✅ Verification successful

Staging secrets usage is consistent and documented

The change to use staging-specific secrets (CPLN_TOKEN_STAGING and CPLN_ORG_STAGING) is valid and aligns with the repository's practices. These secrets are:

  • Used consistently across all deployment workflows
  • Listed as required secrets in the repository's help command
  • Part of the standard deployment configuration
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of required secrets
# Note: This only checks if secrets exist, not their values for security reasons

gh api \
  -H "Accept: application/vnd.github+json" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  /repos/shakacode/react-webpack-rails-tutorial/actions/secrets \
  | jq -r '.secrets[] | select(.name | contains("CPLN")) | .name' \
  | sort

Length of output: 332


Script:

#!/bin/bash
# Check for all CPLN secret references in the workflow
echo "=== Checking CPLN secret references ==="
rg "CPLN_.+_(STAGING|PROD)" .github/workflows/ -A 1 -B 1

echo -e "\n=== Checking for setup documentation ==="
fd "README|SETUP|DEPLOY" --extension md

Length of output: 2770


Script:

#!/bin/bash
# Check README files for secret setup instructions
echo "=== Checking main README ==="
cat README.md | grep -A 5 -B 5 -i "secret\|cpln"

echo -e "\n=== Checking client README ==="
cat client/README.md | grep -A 5 -B 5 -i "secret\|cpln"

Length of output: 252

Copy link

@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: 0

🧹 Nitpick comments (2)
.github/workflows/deploy-to-control-plane.yml (2)

69-69: Simplify the condition.

The condition github.event_name == 'push' && github.event_name != 'issue_comment' is redundant. The second part is unnecessary as the event name can't be both values simultaneously.

-if: github.event_name == 'push' && github.event_name != 'issue_comment'
+if: github.event_name == 'push'

48-49: Clean up trailing spaces.

Multiple lines contain trailing spaces that should be removed for consistency.

Run the following command to remove trailing spaces:

#!/bin/bash
# Remove trailing spaces from the workflow file
sed -i 's/[[:space:]]*$//' .github/workflows/deploy-to-control-plane.yml

Also applies to: 122-124, 152-154, 159-159, 165-167, 197-199

🧰 Tools
🪛 yamllint (1.35.1)

[error] 48-48: trailing spaces

(trailing-spaces)


[error] 49-49: trailing spaces

(trailing-spaces)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a4b0353 and f168a9b.

📒 Files selected for processing (1)
  • .github/workflows/deploy-to-control-plane.yml (10 hunks)
🧰 Additional context used
🪛 yamllint (1.35.1)
.github/workflows/deploy-to-control-plane.yml

[error] 48-48: trailing spaces

(trailing-spaces)


[error] 49-49: trailing spaces

(trailing-spaces)


[error] 122-122: trailing spaces

(trailing-spaces)


[error] 123-123: trailing spaces

(trailing-spaces)


[error] 124-124: trailing spaces

(trailing-spaces)


[error] 152-152: trailing spaces

(trailing-spaces)


[error] 153-153: trailing spaces

(trailing-spaces)


[error] 154-154: trailing spaces

(trailing-spaces)


[error] 159-159: trailing spaces

(trailing-spaces)


[error] 165-165: trailing spaces

(trailing-spaces)


[error] 166-166: trailing spaces

(trailing-spaces)


[error] 167-167: trailing spaces

(trailing-spaces)


[error] 197-197: trailing spaces

(trailing-spaces)


[error] 198-198: trailing spaces

(trailing-spaces)


[error] 199-199: trailing spaces

(trailing-spaces)

🔇 Additional comments (5)
.github/workflows/deploy-to-control-plane.yml (5)

19-20: LGTM! Verify staging secrets are configured.

The change to use staging-specific secrets (CPLN_ORG_STAGING and CPLN_TOKEN_STAGING) improves security by separating staging and production credentials.

Please ensure these staging-specific secrets are properly configured in the repository settings.


46-65: LGTM! Robust PR number handling.

The implementation properly handles both issue comments and push events, with clear error handling and proper use of GitHub CLI for branch-based PR lookup.

🧰 Tools
🪛 yamllint (1.35.1)

[error] 48-48: trailing spaces

(trailing-spaces)


[error] 49-49: trailing spaces

(trailing-spaces)


150-161: LGTM! Safe console link generation.

The implementation safely generates the console link using string concatenation and properly exports it as an environment variable for reuse.

🧰 Tools
🪛 yamllint (1.35.1)

[error] 152-152: trailing spaces

(trailing-spaces)


[error] 153-153: trailing spaces

(trailing-spaces)


[error] 154-154: trailing spaces

(trailing-spaces)


[error] 159-159: trailing spaces

(trailing-spaces)


163-177: LGTM! Consistent and informative status updates.

The status update messages are well-structured with:

  • Appropriate use of emojis for visual clarity
  • Consistent inclusion of console link
  • Proper use of deploy step outputs for the review app URL

Also applies to: 213-224, 259-263

🧰 Tools
🪛 yamllint (1.35.1)

[error] 165-165: trailing spaces

(trailing-spaces)


[error] 166-166: trailing spaces

(trailing-spaces)


[error] 167-167: trailing spaces

(trailing-spaces)


239-240: LGTM! Good step output management.

Adding the id: deploy to the deployment step enables proper referencing of its outputs in subsequent steps.

Copy link

@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 (4)
.github/workflows/deploy-to-control-plane.yml (4)

3-3: Simplify the complex run-name expression

The run-name expression is hard to read and maintain. Consider breaking it down into simpler conditions.

-run-name: ${{ github.event_name == 'issue_comment' && format('Deploying Review App for {0}', github.ref_name) || github.ref == '${{ steps.default-branch.outputs.name }}' && 'Deploying to Staging' || format('Deploying Review App for {0}', github.ref_name) }}
+run-name: ${{ 
+  github.event_name == 'issue_comment' 
+    && format('Deploying Review App for {0}', github.ref_name) 
+    || github.ref == vars.DEFAULT_BRANCH 
+    && 'Deploying to Staging' 
+    || format('Deploying Review App for {0}', github.ref_name) 
+}}

24-30: Improve readability of job conditions

The job conditions are correct but could be more readable by using a cleaner format.

-    if: |
-      (github.event_name == 'issue_comment' && 
-       github.event.issue.pull_request && 
-       github.event.comment.body == '/deploy-review-app') ||
-      github.event_name == 'push' ||
-      github.event_name == 'workflow_dispatch'
+    if: >-
+      github.event_name == 'workflow_dispatch' ||
+      github.event_name == 'push' ||
+      (
+        github.event_name == 'issue_comment' &&
+        github.event.issue.pull_request &&
+        github.event.comment.body == '/deploy-review-app'
+      )
🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 26-26: trailing spaces

(trailing-spaces)


[error] 27-27: trailing spaces

(trailing-spaces)


52-56: Enhance environment variable validation messages

The current validation uses shell parameter expansion which provides generic "not set" messages. Consider adding more descriptive error messages.

-          : "${CPLN_ORG:?Required environment variable not set}"
-          : "${CPLN_TOKEN:?Required environment variable not set}"
-          : "${REVIEW_APP_PREFIX:?Required environment variable not set}"
-          : "${STAGING_APP_NAME:?Required environment variable not set}"
+          if [ -z "${CPLN_ORG}" ]; then
+            echo "Error: CPLN_ORG is required for Control Plane organization identification"
+            exit 1
+          fi
+          if [ -z "${CPLN_TOKEN}" ]; then
+            echo "Error: CPLN_TOKEN is required for Control Plane authentication"
+            exit 1
+          fi
+          if [ -z "${REVIEW_APP_PREFIX}" ]; then
+            echo "Error: REVIEW_APP_PREFIX is required for review app naming"
+            exit 1
+          fi
+          if [ -z "${STAGING_APP_NAME}" ]; then
+            echo "Error: STAGING_APP_NAME is required for staging deployment"
+            exit 1
+          fi

129-153: Simplify workflow URL generation logic

The current implementation has nested try-catch and multiple console.log statements. Consider simplifying it.

-            try {
-              const jobs = await github.rest.actions.listJobsForWorkflowRun({
-                owner: context.repo.owner,
-                repo: context.repo.repo,
-                run_id: context.runId
-              });
-              
-              const currentJob = jobs.data.jobs.find(job => job.name === 'Process-Deployment');
-              if (!currentJob) {
-                console.log('Could not find Process-Deployment job, jobs found:', jobs.data.jobs.map(j => j.name));
-              }
-              const jobId = currentJob?.id;
-              
-              const workflowUrl = jobId
-                ? `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}/job/${jobId}`
-                : `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
-              
-              core.exportVariable('WORKFLOW_URL', workflowUrl);
-              console.log('Set WORKFLOW_URL to:', workflowUrl);
-            } catch (error) {
-              console.log('Error getting job details:', error);
-              // Fallback to run URL
-              const workflowUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
-              core.exportVariable('WORKFLOW_URL', workflowUrl);
-              console.log('Fallback: Set WORKFLOW_URL to:', workflowUrl);
-            }
+            const baseUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
+            let workflowUrl = baseUrl;
+            
+            try {
+              const { data: { jobs } } = await github.rest.actions.listJobsForWorkflowRun({
+                owner: context.repo.owner,
+                repo: context.repo.repo,
+                run_id: context.runId
+              });
+              
+              const jobId = jobs.find(job => job.name === 'Process-Deployment')?.id;
+              if (jobId) {
+                workflowUrl = `${baseUrl}/job/${jobId}`;
+              }
+            } catch (error) {
+              core.warning(`Failed to get job details: ${error.message}`);
+            }
+            
+            core.exportVariable('WORKFLOW_URL', workflowUrl);
+            core.info(`Set WORKFLOW_URL to: ${workflowUrl}`);
🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 135-135: trailing spaces

(trailing-spaces)


[error] 141-141: trailing spaces

(trailing-spaces)


[error] 145-145: trailing spaces

(trailing-spaces)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f168a9b and 3b60bfe.

📒 Files selected for processing (2)
  • .github/workflows/deploy-to-control-plane-staging.yml (0 hunks)
  • .github/workflows/deploy-to-control-plane.yml (4 hunks)
💤 Files with no reviewable changes (1)
  • .github/workflows/deploy-to-control-plane-staging.yml
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/deploy-to-control-plane.yml

62-62: "github.event.comment.body" is potentially untrusted. avoid using it directly in inline scripts. instead, pass it through an environment variable. see https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions for more details

(expression)


205-205: missing input "PR_NUMBER" which is required by action "Build Docker Image" defined at "./.github/actions/build-docker-image". all required inputs are "PR_NUMBER", "app_name", "commit", "org"

(action)

🪛 YAMLlint (1.35.1)
.github/workflows/deploy-to-control-plane.yml

[error] 26-26: trailing spaces

(trailing-spaces)


[error] 27-27: trailing spaces

(trailing-spaces)


[error] 57-57: trailing spaces

(trailing-spaces)


[error] 69-69: trailing spaces

(trailing-spaces)


[error] 89-89: trailing spaces

(trailing-spaces)


[error] 93-93: trailing spaces

(trailing-spaces)


[error] 99-99: trailing spaces

(trailing-spaces)


[error] 100-100: trailing spaces

(trailing-spaces)


[error] 135-135: trailing spaces

(trailing-spaces)


[error] 141-141: trailing spaces

(trailing-spaces)


[error] 145-145: trailing spaces

(trailing-spaces)


[error] 169-169: trailing spaces

(trailing-spaces)


[error] 176-176: trailing spaces

(trailing-spaces)


[error] 274-274: trailing spaces

(trailing-spaces)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test (22.x, 3.3.4)

Comment on lines 99 to 101
elif [[ "${{ github.event_name }}" == "issue_comment" &&
"${{ github.event.issue.pull_request }}" == "true" &&
"${{ github.event.comment.body }}" == "/deploy-review-app" ]]; then
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Secure handling of untrusted input

The workflow uses github.event.comment.body directly in an inline script, which is flagged as a security concern.

-          elif [[ "${{ github.event_name }}" == "issue_comment" && 
-                 "${{ github.event.issue.pull_request }}" == "true" && 
-                 "${{ github.event.comment.body }}" == "/deploy-review-app" ]]; then
+          # Pass potentially untrusted input through environment variable
+          elif [[ "${{ github.event_name }}" == "issue_comment" && 
+                 "${{ github.event.issue.pull_request }}" == "true" && 
+                 "${GITHUB_COMMENT_BODY}" == "/deploy-review-app" ]]; then

Add this to the env section at the job level:

      GITHUB_COMMENT_BODY: ${{ github.event.comment.body }}
🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 99-99: trailing spaces

(trailing-spaces)


[error] 100-100: trailing spaces

(trailing-spaces)

Comment on lines 204 to 209
- name: Build Docker Image
if: |
(github.event_name == 'issue_comment' &&
github.event.issue.pull_request &&
github.event.comment.body == '/deploy-review-app') ||
(steps.get-pr.outputs.has_pr == 'true' && steps.check-app.outputs.app_exists == 'true')
uses: ./.github/actions/build-docker-image
with:
app_name: ${{ env.APP_NAME }}
org: ${{ env.CPLN_ORG }}
commit: ${{ steps.getRef.outputs.PR_SHA }}
PR_NUMBER: ${{ env.PR_NUMBER }}
commit: ${{ steps.setup.outputs.PR_SHA }}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add missing required input for build-docker-image action

The build-docker-image action requires PR_NUMBER input but it's not provided in the workflow.

       - name: Build Docker Image
         uses: ./.github/actions/build-docker-image
         with:
+          PR_NUMBER: ${{ env.PR_NUMBER }}
           app_name: ${{ env.APP_NAME }}
           org: ${{ env.CPLN_ORG }}
           commit: ${{ steps.setup.outputs.PR_SHA }}
📝 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: Build Docker Image
if: |
(github.event_name == 'issue_comment' &&
github.event.issue.pull_request &&
github.event.comment.body == '/deploy-review-app') ||
(steps.get-pr.outputs.has_pr == 'true' && steps.check-app.outputs.app_exists == 'true')
uses: ./.github/actions/build-docker-image
with:
app_name: ${{ env.APP_NAME }}
org: ${{ env.CPLN_ORG }}
commit: ${{ steps.getRef.outputs.PR_SHA }}
PR_NUMBER: ${{ env.PR_NUMBER }}
commit: ${{ steps.setup.outputs.PR_SHA }}
- name: Build Docker Image
uses: ./.github/actions/build-docker-image
with:
PR_NUMBER: ${{ env.PR_NUMBER }}
app_name: ${{ env.APP_NAME }}
org: ${{ env.CPLN_ORG }}
commit: ${{ steps.setup.outputs.PR_SHA }}
🧰 Tools
🪛 actionlint (1.7.4)

205-205: missing input "PR_NUMBER" which is required by action "Build Docker Image" defined at "./.github/actions/build-docker-image". all required inputs are "PR_NUMBER", "app_name", "commit", "org"

(action)


# Use concurrency to cancel in-progress runs
concurrency:
group: deploy-pr-${{ github.event.issue.number }}
group: ${{ github.ref == '${{ steps.default-branch.outputs.name }}' && 'deploy-staging' || format('deploy-pr-{0}', github.event.issue.number) }}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix the concurrency group expression

The concurrency group references steps.default-branch.outputs.name which isn't defined yet as steps are executed sequentially. This could lead to unexpected behavior.

-  group: ${{ github.ref == '${{ steps.default-branch.outputs.name }}' && 'deploy-staging' || format('deploy-pr-{0}', github.event.issue.number) }}
+  group: ${{ github.ref == vars.DEFAULT_BRANCH && 'deploy-staging' || format('deploy-pr-{0}', github.event.issue.number) }}
📝 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
group: ${{ github.ref == '${{ steps.default-branch.outputs.name }}' && 'deploy-staging' || format('deploy-pr-{0}', github.event.issue.number) }}
group: ${{ github.ref == vars.DEFAULT_BRANCH && 'deploy-staging' || format('deploy-pr-{0}', github.event.issue.number) }}

Copy link

github-actions bot commented Jan 27, 2025

❌ Deployment failed!

📝 View Deploy Logs

Copy link

@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: 0

🧹 Nitpick comments (1)
.github/workflows/deploy-to-control-plane.yml (1)

9-11: Consider restricting branch patterns.

The current pattern allows deployments from all branches except gh-pages. This could lead to unnecessary workflow runs and potential resource wastage.

     branches:
-      - '**'        # Allow all branches
+      - 'main'      # Main branch
+      - 'develop'   # Development branch
+      - 'feature/*' # Feature branches
       - '!gh-pages' # Exclude gh-pages if it exists
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3b60bfe and 1601222.

📒 Files selected for processing (1)
  • .github/workflows/deploy-to-control-plane.yml (6 hunks)
🧰 Additional context used
🪛 YAMLlint (1.35.1)
.github/workflows/deploy-to-control-plane.yml

[error] 26-26: trailing spaces

(trailing-spaces)


[error] 27-27: trailing spaces

(trailing-spaces)


[error] 54-54: trailing spaces

(trailing-spaces)


[error] 59-59: trailing spaces

(trailing-spaces)


[error] 109-109: trailing spaces

(trailing-spaces)


[error] 113-113: trailing spaces

(trailing-spaces)


[error] 119-119: trailing spaces

(trailing-spaces)


[error] 123-123: trailing spaces

(trailing-spaces)


[error] 124-124: trailing spaces

(trailing-spaces)


[error] 151-151: trailing spaces

(trailing-spaces)


[error] 157-157: trailing spaces

(trailing-spaces)


[error] 161-161: trailing spaces

(trailing-spaces)


[error] 184-184: trailing spaces

(trailing-spaces)


[error] 191-191: trailing spaces

(trailing-spaces)


[error] 289-289: trailing spaces

(trailing-spaces)

🪛 actionlint (1.7.4)
.github/workflows/deploy-to-control-plane.yml

95-95: "github.event.comment.body" is potentially untrusted. avoid using it directly in inline scripts. instead, pass it through an environment variable. see https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions for more details

(expression)


220-220: missing input "PR_NUMBER" which is required by action "Build Docker Image" defined at "./.github/actions/build-docker-image". all required inputs are "PR_NUMBER", "app_name", "commit", "org"

(action)

🔇 Additional comments (6)
.github/workflows/deploy-to-control-plane.yml (6)

18-18: Fix the concurrency group expression.

The concurrency group references steps.default-branch.outputs.name which isn't defined yet as steps are executed sequentially.

-  group: ${{ github.ref == '${{ steps.default-branch.outputs.name }}' && 'deploy-staging' || format('deploy-pr-{0}', github.event.issue.number) }}
+  group: ${{ github.ref == vars.DEFAULT_BRANCH && 'deploy-staging' || format('deploy-pr-{0}', github.event.issue.number) }}

37-42: LGTM! Well-structured environment configuration.

Good use of GitHub Variables (vars) for non-sensitive values and Secrets for sensitive data.


123-125: Secure handling of untrusted input.

The workflow uses github.event.comment.body directly in an inline script, which is flagged as a security concern.

-          elif [[ "${{ github.event_name }}" == "issue_comment" && 
-                 "${{ github.event.issue.pull_request }}" == "true" && 
-                 "${{ github.event.comment.body }}" == "/deploy-review-app" ]]; then
+          # Pass potentially untrusted input through environment variable
+          elif [[ "${{ github.event_name }}" == "issue_comment" && 
+                 "${{ github.event.issue.pull_request }}" == "true" && 
+                 "${GITHUB_COMMENT_BODY}" == "/deploy-review-app" ]]; then

Add this to the env section at the job level:

      GITHUB_COMMENT_BODY: ${{ github.event.comment.body }}
🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 123-123: trailing spaces

(trailing-spaces)


[error] 124-124: trailing spaces

(trailing-spaces)


49-60: LGTM! Thorough environment variable verification.

Excellent implementation of environment variable verification with clear error messages.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 54-54: trailing spaces

(trailing-spaces)


[error] 59-59: trailing spaces

(trailing-spaces)


219-224: Add missing required input for build-docker-image action.

The build-docker-image action requires PR_NUMBER input but it's not provided in the workflow.

       - name: Build Docker Image
         uses: ./.github/actions/build-docker-image
         with:
+          PR_NUMBER: ${{ env.PR_NUMBER }}
           app_name: ${{ env.APP_NAME }}
           org: ${{ env.CPLN_ORG }}
           commit: ${{ steps.setup.outputs.PR_SHA }}
🧰 Tools
🪛 actionlint (1.7.4)

220-220: missing input "PR_NUMBER" which is required by action "Build Docker Image" defined at "./.github/actions/build-docker-image". all required inputs are "PR_NUMBER", "app_name", "commit", "org"

(action)


172-193: LGTM! Comprehensive status updates.

The implementation provides clear and detailed feedback throughout the deployment process with appropriate status indicators and links to logs.

Also applies to: 277-295

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 184-184: trailing spaces

(trailing-spaces)


[error] 191-191: trailing spaces

(trailing-spaces)

Copy link

github-actions bot commented Jan 27, 2025

❌ Deployment failed!

📝 View Deploy Logs

Copy link

github-actions bot commented Jan 27, 2025

❌ Deployment failed!

📝 View Deploy Logs

@justin808
Copy link
Member Author

/deploy-review-app

@justin808
Copy link
Member Author

/deploy-review-app

@justin808
Copy link
Member Author

/deploy-review-app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant