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

Github actions fixes #618

Merged
merged 14 commits into from
Jan 26, 2025
Merged

Github actions fixes #618

merged 14 commits into from
Jan 26, 2025

Conversation

justin808
Copy link
Member

@justin808 justin808 commented Jan 26, 2025

This change is Reviewable

Summary by CodeRabbit

Release Notes

  • New Features

    • Added validation for required secrets in deployment workflows.
    • Introduced multiple status update steps during deployment for better feedback.
    • Added a new workflow to provide quick help on pull request creation.
  • Workflow Updates

    • Refined deployment triggers to focus on issue comments and push events.
    • Restructured steps for improved clarity and information during review app deletion.
    • Updated help command to reflect changes in command names and structure.
  • Improvements

    • Enhanced error handling and logging in deployment scripts.
    • Streamlined deployment process with checks for existing review apps.
    • Simplified workflow configuration for better readability and management.

Copy link

coderabbitai bot commented Jan 26, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request introduces changes to GitHub Actions workflows and scripts related to deploying and managing review applications. Key modifications include adding a step to validate required secrets, restructuring the deployment workflow to respond only to issue comments and push events, and enhancing error handling in the deployment scripts. New steps have been added to provide status updates during deployment, and existing steps have been modified for clarity and functionality.

Changes

File Change Summary
.github/actions/deploy-to-control-plane/action.yml Added new input wait_timeout, new steps for validating secrets, initializing deployment, and updating status messages. Modified deployment logic to check for existing Control Plane apps.
.github/actions/deploy-to-control-plane/scripts/deploy.sh Restructured for improved error handling, added workload readiness verification with detailed error messages.
.github/workflows/add-comment-on-pr-creation.yml Reformatted workflow file for improved readability without functional changes.
.github/workflows/delete-review-app.yml Renamed and restructured steps, exported WORKFLOW_URL, and improved comment generation with links to logs.
.github/workflows/deploy-to-control-plane.yml Removed pull_request event trigger, simplified deployment logic to respond only to issue comments and push events. Updated environment variables and job conditions accordingly.
.github/workflows/help-command.yml Updated help message to reflect new command names, changing /deploy to /deploy-review-app.
.github/workflows/review-app-help.yml Introduced new workflow for providing quick help on pull request creation with commands available for review apps.

Possibly related PRs

  • Fix/no commit hash on the deployed project #611: The changes in this PR involve adding a GIT_COMMIT_SHA environment variable to the Dockerfile, which is relevant to the deployment process described in the main PR that modifies deployment logic and includes steps for handling commit SHAs.
  • Improvements to deployments #615: This PR also introduces a GIT_COMMIT_SHA environment variable in the Dockerfile, which aligns with the main PR's focus on deployment steps that utilize commit SHAs.
  • delete-on-pr-close #617: This PR modifies the workflow for deleting review apps, which is related to the deployment process as it involves managing the lifecycle of applications deployed to the Control Plane, similar to the deployment updates in the main PR.

Poem

🐰 In the land of code where bunnies play,
Deployments hop along the way.
Secrets checked, and apps anew,
With every step, the joy just grew!
A dance of scripts, a cheerful cheer,
Deploying dreams, the time is near! 🚀


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1917948 and fcc1ce0.

📒 Files selected for processing (5)
  • .github/actions/deploy-to-control-plane/action.yml (1 hunks)
  • .github/actions/deploy-to-control-plane/scripts/deploy.sh (2 hunks)
  • .github/workflows/delete-review-app.yml (5 hunks)
  • .github/workflows/help-command.yml (3 hunks)
  • .github/workflows/review-app-help.yml (1 hunks)

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

github-actions bot commented Jan 26, 2025

Deploying to Control Plane...

Waiting for deployment to be ready...

View Deploy Logs

Control Plane Console for Review App with PR #618

@justin808
Copy link
Member Author

/deploy-review-app

Copy link

github-actions bot commented Jan 26, 2025

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: 1

🧹 Nitpick comments (3)
.github/actions/deploy-to-control-plane/scripts/deploy.sh (1)

40-44: Consider adding URL format validation.

The RAILS_URL extraction could benefit from a more strict validation to ensure the URL matches the expected format.

 # Extract app URL from deployment output
 RAILS_URL=$(grep -oP 'https://rails-[^[:space:]]*\.cpln\.app(?=\s|$)' "$TEMP_OUTPUT" | head -n1)
+if ! [[ "$RAILS_URL" =~ ^https://rails-[a-zA-Z0-9-]+\.cpln\.app$ ]]; then
+  echo "❌ Invalid app URL format: $RAILS_URL"
+  exit 1
+fi
 if [ -z "$RAILS_URL" ]; then
.github/workflows/delete-review-app.yml (1)

Line range hint 96-114: Remove trailing whitespace.

There's a trailing space on line 97.

-eval(process.env.GET_CONSOLE_LINK); 
+eval(process.env.GET_CONSOLE_LINK);
.github/workflows/deploy-to-control-plane.yml (1)

23-25: Remove trailing spaces in conditions.

There are trailing spaces in the conditional statements.

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

[error] 23-23: trailing spaces

(trailing-spaces)


[error] 24-24: 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 4bf2c03 and 34603d8.

📒 Files selected for processing (6)
  • .github/actions/deploy-to-control-plane/action.yml (1 hunks)
  • .github/actions/deploy-to-control-plane/scripts/deploy.sh (2 hunks)
  • .github/workflows/add-comment-on-pr-creation.yml (1 hunks)
  • .github/workflows/delete-review-app.yml (4 hunks)
  • .github/workflows/deploy-to-control-plane.yml (1 hunks)
  • .github/workflows/help-command.yml (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .github/workflows/add-comment-on-pr-creation.yml
🧰 Additional context used
🪛 yamllint (1.35.1)
.github/workflows/delete-review-app.yml

[error] 97-97: trailing spaces

(trailing-spaces)

.github/workflows/deploy-to-control-plane.yml

[error] 23-23: trailing spaces

(trailing-spaces)


[error] 24-24: trailing spaces

(trailing-spaces)

🔇 Additional comments (4)
.github/actions/deploy-to-control-plane/scripts/deploy.sh (2)

34-38: LGTM! Good error handling improvements.

The deployment command now has proper error handling with timeout and clear error messaging.


47-59: LGTM! Robust workload readiness check.

The implementation includes:

  • Clear timeout handling
  • Differentiation between timeout and other failures
  • Comprehensive error output
.github/workflows/help-command.yml (1)

Line range hint 34-55: LGTM! Clear and consistent command documentation.

The help message is well-structured and accurately reflects the updated command names.

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

Line range hint 63-89: LGTM! Well-structured workflow URL handling.

The implementation provides clear workflow URLs and proper error handling.

Comment on lines 40 to 46
- name: Setup Control Plane App If It Doesn't Exist
shell: bash
run: |
if ! cpflow exists -a ${{ inputs.app_name }} ; then
echo " Setting up new Control Plane app for app ${{ inputs.app_name }}..."
cpflow setup-app -a ${{ inputs.app_name }}
fi
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add error handling for the setup-app command.

The setup command should include error handling to ensure the app is created successfully.

 if ! cpflow exists -a ${{ inputs.app_name }} ; then
   echo " Setting up new Control Plane app for app ${{ inputs.app_name }}..."
-  cpflow setup-app -a ${{ inputs.app_name }}
+  if ! cpflow setup-app -a ${{ inputs.app_name }}; then
+    echo "❌ Failed to set up Control Plane app"
+    exit 1
+  fi
 fi
📝 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: Setup Control Plane App If It Doesn't Exist
shell: bash
run: |
if ! cpflow exists -a ${{ inputs.app_name }} ; then
echo " Setting up new Control Plane app for app ${{ inputs.app_name }}..."
cpflow setup-app -a ${{ inputs.app_name }}
fi
- name: Setup Control Plane App If It Doesn't Exist
shell: bash
run: |
if ! cpflow exists -a ${{ inputs.app_name }} ; then
echo " Setting up new Control Plane app for app ${{ inputs.app_name }}..."
if ! cpflow setup-app -a ${{ inputs.app_name }}; then
echo "❌ Failed to set up Control Plane app"
exit 1
fi
fi

@justin808
Copy link
Member Author

/destroy-review-app

Copy link

github-actions bot commented Jan 26, 2025

Copy link

github-actions bot commented Jan 26, 2025

Copy link

github-actions bot commented Jan 26, 2025

Copy link

github-actions bot commented Jan 26, 2025

🚀 Deploying to Control Plane...

⏳ Waiting for deployment to be ready...

📝 View Deploy Logs

🎮 Control Plane Console

@justin808
Copy link
Member Author

/help

Copy link

Available Commands

/deploy-review-app

Deploys your PR branch to a review environment on Control Plane.

  • Creates a new review app if one doesn't exist
  • Updates the existing review app if it already exists
  • Provides a unique URL to preview your changes
  • Shows build and deployment progress in real-time

/delete-review-app

Deletes the review app associated with this PR.

  • Removes all resources from Control Plane
  • Helpful for cleaning up when you're done testing
  • Can be re-deployed later using /deploy-review-app

/help

Shows this help message explaining available commands.


Note: These commands only work in pull request comments.

Copy link

github-actions bot commented Jan 26, 2025

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 (6)
.github/actions/deploy-to-control-plane/scripts/deploy.sh (2)

43-48: Consider enhancing deployment error messages.

While the error handling is good, consider making the error messages more specific to help diagnose deployment failures more quickly.

 if ! timeout "${WAIT_TIMEOUT}" cpflow deploy-image -a "$APP_NAME" --run-release-phase --org "$CPLN_ORG" --verbose 2>&1 | tee "$TEMP_OUTPUT"; then
-  echo "❌ Deployment failed"
+  if [ $? -eq 124 ]; then
+    echo "❌ Deployment timed out after ${WAIT_TIMEOUT} seconds"
+  else
+    echo "❌ Deployment failed with exit code $?"
+  fi
   echo "Full output:"
   cat "$TEMP_OUTPUT"
   exit 1
 fi

50-57: Consider adding URL format validation.

While the URL extraction works, consider adding validation to ensure the extracted URL matches the expected format.

 RAILS_URL=$(grep -oP 'https://rails-[^[:space:]]*\.cpln\.app(?=\s|$)' "$TEMP_OUTPUT" | head -n1)
 if [ -z "$RAILS_URL" ]; then
   echo "❌ Failed to get app URL from deployment output"
   echo "Full output:"
   cat "$TEMP_OUTPUT"
   exit 1
+elif ! [[ "$RAILS_URL" =~ ^https://rails-[a-zA-Z0-9-]+\.cpln\.app$ ]]; then
+  echo "❌ Extracted URL does not match expected format: $RAILS_URL"
+  exit 1
 fi
.github/workflows/delete-review-app.yml (1)

Line range hint 63-89: Consider extracting workflow URL logic to a reusable action.

The workflow URL generation logic is duplicated across multiple workflow files. Consider extracting it to a reusable composite action.

Example structure:

# .github/actions/get-workflow-url/action.yml
name: 'Get Workflow URL'
description: 'Gets the URL for the current workflow run'
outputs:
  url:
    description: 'The workflow URL'
runs:
  using: "composite"
  steps:
    - uses: actions/github-script@v7
      with:
        script: |
          async function getWorkflowUrl(runId) {
            // Current implementation...
          }
          const url = await getWorkflowUrl(context.runId);
          core.setOutput('url', url);
.github/actions/deploy-to-control-plane/action.yml (2)

47-108: Add error handling for GitHub API calls.

While the workflow URL retrieval has good error handling, the deployment creation and comment creation could benefit from try-catch blocks to handle potential API failures gracefully.

 const comment = await github.rest.issues.createComment({
   owner: context.repo.owner,
   repo: context.repo.repo,
   issue_number: process.env.PR_NUMBER,
   body: ' Initializing deployment...'
-});
+}).catch(error => {
+  core.error(`Failed to create comment: ${error.message}`);
+  throw error;
+});

 const deployment = await github.rest.repos.createDeployment({
   owner: context.repo.owner,
   repo: context.repo.repo,
   ref: context.sha,
   environment: 'review',
   auto_merge: false,
   required_contexts: []
-});
+}).catch(error => {
+  core.error(`Failed to create deployment: ${error.message}`);
+  throw error;
+});
🧰 Tools
🪛 yamllint (1.35.1)

[error] 54-54: trailing spaces

(trailing-spaces)


[error] 73-73: trailing spaces

(trailing-spaces)


[error] 76-76: trailing spaces

(trailing-spaces)


[error] 81-81: trailing spaces

(trailing-spaces)


[error] 84-84: trailing spaces

(trailing-spaces)


[error] 92-92: trailing spaces

(trailing-spaces)


[error] 104-104: trailing spaces

(trailing-spaces)


154-196: Well-structured status updates with consistent formatting!

The status updates provide excellent visibility into the deployment process. Consider adding error handling for the status update API calls to ensure users are informed even if updates fail.

🧰 Tools
🪛 yamllint (1.35.1)

[error] 167-167: trailing spaces

(trailing-spaces)


[error] 190-190: trailing spaces

(trailing-spaces)

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

9-11: Consider using pattern matching for branch exclusions.

The branch exclusion could be more maintainable using a pattern.

 branches-ignore:
-      - main   # Don't run on main branch pushes
-      - master # Don't run on master branch pushes
+      - '{main,master}' # Don't run on production branches
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 34603d8 and 1917948.

📒 Files selected for processing (4)
  • .github/actions/deploy-to-control-plane/action.yml (1 hunks)
  • .github/actions/deploy-to-control-plane/scripts/deploy.sh (2 hunks)
  • .github/workflows/delete-review-app.yml (5 hunks)
  • .github/workflows/deploy-to-control-plane.yml (5 hunks)
🧰 Additional context used
🪛 yamllint (1.35.1)
.github/workflows/deploy-to-control-plane.yml

[error] 27-27: trailing spaces

(trailing-spaces)


[error] 28-28: trailing spaces

(trailing-spaces)


[error] 84-84: trailing spaces

(trailing-spaces)


[error] 85-85: trailing spaces

(trailing-spaces)


[error] 86-86: trailing spaces

(trailing-spaces)


[error] 97-97: trailing spaces

(trailing-spaces)


[error] 98-98: trailing spaces

(trailing-spaces)


[error] 99-99: trailing spaces

(trailing-spaces)


[error] 116-116: trailing spaces

(trailing-spaces)


[error] 117-117: trailing spaces

(trailing-spaces)


[error] 118-118: trailing spaces

(trailing-spaces)


[error] 124-124: trailing spaces

(trailing-spaces)


[error] 125-125: trailing spaces

(trailing-spaces)


[error] 126-126: trailing spaces

(trailing-spaces)


[error] 153-153: trailing spaces

(trailing-spaces)


[error] 160-160: trailing spaces

(trailing-spaces)


[error] 161-161: trailing spaces

(trailing-spaces)


[error] 162-162: trailing spaces

(trailing-spaces)


[error] 186-186: trailing spaces

(trailing-spaces)


[error] 187-187: trailing spaces

(trailing-spaces)


[error] 188-188: trailing spaces

(trailing-spaces)


[error] 194-194: trailing spaces

(trailing-spaces)


[error] 195-195: trailing spaces

(trailing-spaces)


[error] 196-196: trailing spaces

(trailing-spaces)


[error] 207-207: trailing spaces

(trailing-spaces)


[error] 208-208: trailing spaces

(trailing-spaces)


[error] 209-209: trailing spaces

(trailing-spaces)


[error] 235-235: trailing spaces

(trailing-spaces)


[error] 236-236: trailing spaces

(trailing-spaces)


[error] 237-237: trailing spaces

(trailing-spaces)


[error] 265-265: trailing spaces

(trailing-spaces)

.github/actions/deploy-to-control-plane/action.yml

[error] 38-38: trailing spaces

(trailing-spaces)


[error] 54-54: trailing spaces

(trailing-spaces)


[error] 73-73: trailing spaces

(trailing-spaces)


[error] 76-76: trailing spaces

(trailing-spaces)


[error] 81-81: trailing spaces

(trailing-spaces)


[error] 84-84: trailing spaces

(trailing-spaces)


[error] 92-92: trailing spaces

(trailing-spaces)


[error] 104-104: trailing spaces

(trailing-spaces)


[error] 128-128: trailing spaces

(trailing-spaces)


[error] 167-167: trailing spaces

(trailing-spaces)


[error] 190-190: trailing spaces

(trailing-spaces)


[error] 218-218: trailing spaces

(trailing-spaces)


[error] 229-229: trailing spaces

(trailing-spaces)


[error] 231-231: trailing spaces

(trailing-spaces)


[error] 242-242: trailing spaces

(trailing-spaces)


[error] 250-250: trailing spaces

(trailing-spaces)

.github/workflows/delete-review-app.yml

[error] 97-97: trailing spaces

(trailing-spaces)

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

51-51: shellcheck reported issue in this script: SC2086:info:4:34: Double quote to prevent globbing and word splitting

(shellcheck)


51-51: shellcheck reported issue in this script: SC2086:info:5:68: Double quote to prevent globbing and word splitting

(shellcheck)


51-51: shellcheck reported issue in this script: SC2086:info:6:25: Double quote to prevent globbing and word splitting

(shellcheck)


65-65: shellcheck reported issue in this script: SC2086:info:1:54: Double quote to prevent globbing and word splitting

(shellcheck)


65-65: shellcheck reported issue in this script: SC2086:info:2:88: Double quote to prevent globbing and word splitting

(shellcheck)


74-74: shellcheck reported issue in this script: SC2086:info:5:27: Double quote to prevent globbing and word splitting

(shellcheck)


88-88: shellcheck reported issue in this script: SC2086:info:2:60: Double quote to prevent globbing and word splitting

(shellcheck)


88-88: shellcheck reported issue in this script: SC2086:info:3:59: Double quote to prevent globbing and word splitting

(shellcheck)


120-120: shellcheck reported issue in this script: SC2086:info:1:85: Double quote to prevent globbing and word splitting

(shellcheck)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Process-Deployment-Command
🔇 Additional comments (10)
.github/actions/deploy-to-control-plane/scripts/deploy.sh (3)

Line range hint 4-22: Well-structured environment validation!

Good practices implemented:

  • Early validation of required environment variables
  • Default timeout with numeric validation
  • Clear error messages

32-39: Robust Docker image build implementation!

Good practices implemented:

  • Secure use of mktemp for temporary file
  • Proper cleanup with trap
  • Comprehensive error handling with build output capture

59-70: Well-implemented workload readiness check!

Good practices implemented:

  • Clear differentiation between timeout and other failures
  • Proper exit code handling
  • Good use of timeout with bash -c
.github/workflows/delete-review-app.yml (2)

Line range hint 29-42: Good security practice with secrets validation!

Well-implemented validation of required secrets before proceeding with deletion.


Line range hint 136-157: Well-structured status updates!

Good practices implemented:

  • Clear success/failure differentiation
  • Helpful links to logs and resources
  • Good use of conditional messaging
🧰 Tools
🪛 yamllint (1.35.1)

[error] 144-144: trailing spaces

(trailing-spaces)

.github/actions/deploy-to-control-plane/action.yml (4)

29-42: Great addition of early secret validation!

The validation step for required secrets is a good security practice that fails fast and provides clear error messages.

🧰 Tools
🪛 yamllint (1.35.1)

[error] 38-38: trailing spaces

(trailing-spaces)


198-206: Clean deployment configuration with good separation of concerns!

The deployment step is well-structured with:

  • Externalized deployment logic
  • Proper environment variable handling
  • Configurable timeout

207-257: Excellent error handling and status reporting!

The final status update provides comprehensive information with:

  • Both success and failure handling
  • GitHub deployment status updates
  • Clear and informative messages
🧰 Tools
🪛 yamllint (1.35.1)

[error] 218-218: trailing spaces

(trailing-spaces)


[error] 229-229: trailing spaces

(trailing-spaces)


[error] 231-231: trailing spaces

(trailing-spaces)


[error] 242-242: trailing spaces

(trailing-spaces)


[error] 250-250: trailing spaces

(trailing-spaces)


136-152: 🛠️ Refactor suggestion

Add error handling for app creation.

While the template application has error handling, the app creation step should also include error handling.

 if ! cpflow exists -a ${{ inputs.app_name }} ; then
   echo "📦 Setting up new Control Plane app..."
-  cpflow setup-app -a ${{ inputs.app_name }}
+  if ! cpflow setup-app -a ${{ inputs.app_name }}; then
+    echo "❌ Failed to create Control Plane app"
+    exit 1
+  fi
 fi

Likely invalid or redundant comment.

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

234-247: Well-structured deployment configuration!

The deployment step is well-organized with:

  • Proper use of composite action
  • Secure handling of secrets
  • Configurable timeout with fallback
🧰 Tools
🪛 yamllint (1.35.1)

[error] 235-235: trailing spaces

(trailing-spaces)


[error] 236-236: trailing spaces

(trailing-spaces)


[error] 237-237: trailing spaces

(trailing-spaces)

Comment on lines +69 to +79
- name: Check if Review App Exists
id: check-app
if: github.event_name == 'push' && steps.get-pr.outputs.has_pr == 'true'
env:
CPLN_TOKEN: ${{ secrets.CPLN_TOKEN }}
run: |
if ! cpflow exists -a ${{ env.APP_NAME }}; then
echo "No review app exists for this PR"
exit 0
fi
echo "app_exists=true" >> $GITHUB_OUTPUT
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add error handling for Control Plane CLI command.

The app existence check should handle potential CLI failures.

-if ! cpflow exists -a ${{ env.APP_NAME }}; then
+if ! cpflow exists -a "${{ env.APP_NAME }}" 2>/dev/null; then
   echo "No review app exists for this PR"
   exit 0
+elif [ $? -gt 1 ]; then
+  echo "❌ Failed to check if app exists"
+  exit 1
 fi
-echo "app_exists=true" >> $GITHUB_OUTPUT
+echo "app_exists=true" >> "$GITHUB_OUTPUT"
📝 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 if Review App Exists
id: check-app
if: github.event_name == 'push' && steps.get-pr.outputs.has_pr == 'true'
env:
CPLN_TOKEN: ${{ secrets.CPLN_TOKEN }}
run: |
if ! cpflow exists -a ${{ env.APP_NAME }}; then
echo "No review app exists for this PR"
exit 0
fi
echo "app_exists=true" >> $GITHUB_OUTPUT
- name: Check if Review App Exists
id: check-app
if: github.event_name == 'push' && steps.get-pr.outputs.has_pr == 'true'
env:
CPLN_TOKEN: ${{ secrets.CPLN_TOKEN }}
run: |
if ! cpflow exists -a "${{ env.APP_NAME }}" 2>/dev/null; then
echo "No review app exists for this PR"
exit 0
elif [ $? -gt 1 ]; then
echo "❌ Failed to check if app exists"
exit 1
fi
echo "app_exists=true" >> "$GITHUB_OUTPUT"
🧰 Tools
🪛 actionlint (1.7.4)

74-74: shellcheck reported issue in this script: SC2086:info:5:27: Double quote to prevent globbing and word splitting

(shellcheck)

Comment on lines +46 to +68
- name: Get PR Number for Push Event
if: github.event_name == 'push'
id: get-pr
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
missing_secrets=()
for secret in "CPLN_TOKEN" "CPLN_ORG"; do
if [ -z "${!secret}" ]; then
missing_secrets+=("$secret")
fi
done

if [ ${#missing_secrets[@]} -ne 0 ]; then
echo "Required secrets are not set: ${missing_secrets[*]}"
exit 1
# Get PR number from branch
PR_NUMBER=$(gh pr list --head ${{ github.ref_name }} --json number --jq '.[0].number')
if [ -n "$PR_NUMBER" ]; then
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
echo "APP_NAME=qa-react-webpack-rails-tutorial-pr-$PR_NUMBER" >> $GITHUB_ENV
echo "has_pr=true" >> $GITHUB_OUTPUT
else
echo "No PR found for this branch"
exit 0
fi

- name: Setup Environment
uses: ./.github/actions/setup-environment
- name: Set PR Number for Comment Event
if: github.event_name == 'issue_comment'
run: |
echo "PR_NUMBER=${{ github.event.issue.number }}" >> $GITHUB_ENV
echo "APP_NAME=qa-react-webpack-rails-tutorial-pr-${{ github.event.issue.number }}" >> $GITHUB_ENV

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add error handling and fix shell script quoting.

The PR number handling could be improved with better shell scripting practices.

 # Get PR number from branch
-PR_NUMBER=$(gh pr list --head ${{ github.ref_name }} --json number --jq '.[0].number')
+PR_NUMBER=$(gh pr list --head "${{ github.ref_name }}" --json number --jq '.[0].number') || {
+  echo "Failed to get PR number"
+  exit 1
+}
 if [ -n "$PR_NUMBER" ]; then
-  echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
-  echo "APP_NAME=qa-react-webpack-rails-tutorial-pr-$PR_NUMBER" >> $GITHUB_ENV
+  {
+    echo "PR_NUMBER=${PR_NUMBER}" >> "$GITHUB_ENV"
+    echo "APP_NAME=qa-react-webpack-rails-tutorial-pr-${PR_NUMBER}" >> "$GITHUB_ENV"
+  } || {
+    echo "Failed to set environment variables"
+    exit 1
+  }
   echo "has_pr=true" >> $GITHUB_OUTPUT
 else
   echo "No PR found for this branch"
   exit 0
 fi
📝 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: Get PR Number for Push Event
if: github.event_name == 'push'
id: get-pr
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
missing_secrets=()
for secret in "CPLN_TOKEN" "CPLN_ORG"; do
if [ -z "${!secret}" ]; then
missing_secrets+=("$secret")
fi
done
if [ ${#missing_secrets[@]} -ne 0 ]; then
echo "Required secrets are not set: ${missing_secrets[*]}"
exit 1
# Get PR number from branch
PR_NUMBER=$(gh pr list --head ${{ github.ref_name }} --json number --jq '.[0].number')
if [ -n "$PR_NUMBER" ]; then
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
echo "APP_NAME=qa-react-webpack-rails-tutorial-pr-$PR_NUMBER" >> $GITHUB_ENV
echo "has_pr=true" >> $GITHUB_OUTPUT
else
echo "No PR found for this branch"
exit 0
fi
- name: Setup Environment
uses: ./.github/actions/setup-environment
- name: Set PR Number for Comment Event
if: github.event_name == 'issue_comment'
run: |
echo "PR_NUMBER=${{ github.event.issue.number }}" >> $GITHUB_ENV
echo "APP_NAME=qa-react-webpack-rails-tutorial-pr-${{ github.event.issue.number }}" >> $GITHUB_ENV
- name: Get PR Number for Push Event
if: github.event_name == 'push'
id: get-pr
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Get PR number from branch
PR_NUMBER=$(gh pr list --head "${{ github.ref_name }}" --json number --jq '.[0].number') || {
echo "Failed to get PR number"
exit 1
}
if [ -n "$PR_NUMBER" ]; then
{
echo "PR_NUMBER=${PR_NUMBER}" >> "$GITHUB_ENV"
echo "APP_NAME=qa-react-webpack-rails-tutorial-pr-${PR_NUMBER}" >> "$GITHUB_ENV"
} || {
echo "Failed to set environment variables"
exit 1
}
echo "has_pr=true" >> $GITHUB_OUTPUT
else
echo "No PR found for this branch"
exit 0
fi
- name: Set PR Number for Comment Event
if: github.event_name == 'issue_comment'
run: |
echo "PR_NUMBER=${{ github.event.issue.number }}" >> $GITHUB_ENV
echo "APP_NAME=qa-react-webpack-rails-tutorial-pr-${{ github.event.issue.number }}" >> $GITHUB_ENV
🧰 Tools
🪛 actionlint (1.7.4)

51-51: shellcheck reported issue in this script: SC2086:info:4:34: Double quote to prevent globbing and word splitting

(shellcheck)


51-51: shellcheck reported issue in this script: SC2086:info:5:68: Double quote to prevent globbing and word splitting

(shellcheck)


51-51: shellcheck reported issue in this script: SC2086:info:6:25: Double quote to prevent globbing and word splitting

(shellcheck)


65-65: shellcheck reported issue in this script: SC2086:info:1:54: Double quote to prevent globbing and word splitting

(shellcheck)


65-65: shellcheck reported issue in this script: SC2086:info:2:88: Double quote to prevent globbing and word splitting

(shellcheck)

Comment on lines +249 to +270
- name: Update Status - Success
if: success()
uses: actions/github-script@v7
with:
script: |
eval(process.env.GET_CONSOLE_LINK);

const prNumber = process.env.PR_NUMBER;
const appUrl = process.env.REVIEW_APP_URL;
const workflowUrl = process.env.WORKFLOW_URL;
const isSuccess = '${{ job.status }}' === 'success';

// Create GitHub deployment status
const deploymentStatus = {
owner: context.repo.owner,
repo: context.repo.repo,
deployment_id: ${{ fromJSON(steps.init-deployment.outputs.result).deploymentId }},
state: isSuccess ? 'success' : 'failure',
environment_url: isSuccess ? appUrl : undefined,
log_url: workflowUrl,
environment: 'review'
};

await github.rest.repos.createDeploymentStatus(deploymentStatus);

// Define messages based on deployment status
const successMessage = [
' Deployment complete for PR #' + prNumber + ', commit ' + '${{ env.COMMIT_HASH }}',
'',
' [Review App for PR #' + prNumber + '](' + appUrl + ')',
'',
' [View Completed Action Build and Deploy Logs](' + workflowUrl + ')',
'✅ Deployment successful!',
'',
getConsoleLink(prNumber)
].join('\n');

const failureMessage = [
' Deployment failed for PR #' + prNumber + ', commit ' + '${{ env.COMMIT_HASH }}',
'🌐 Review app is ready at: ${{ env.REVIEW_APP_URL }}',
'',
' [View Deployment Logs with Errors](' + workflowUrl + ')',
'📝 [View App Logs](' + process.env.WORKFLOW_URL + ')',
'',
getConsoleLink(prNumber)
getConsoleLink(process.env.PR_NUMBER)
].join('\n');

// Update the existing comment
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: process.env.COMMENT_ID,
body: isSuccess ? successMessage : failureMessage
body: successMessage
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add failure status update handler.

While success status is well handled, consider adding a failure handler to provide clear error feedback.

+      - name: Update Status - Failure
+        if: failure()
+        uses: actions/github-script@v7
+        with:
+          script: |
+            eval(process.env.GET_CONSOLE_LINK);
+
+            const failureMessage = [
+              '❌ Deployment failed!',
+              '',
+              '📝 [View Error Logs](' + process.env.WORKFLOW_URL + ')',
+              '',
+              getConsoleLink(process.env.PR_NUMBER)
+            ].join('\n');
+            
+            await github.rest.issues.updateComment({
+              owner: context.repo.owner,
+              repo: context.repo.repo,
+              comment_id: process.env.COMMENT_ID,
+              body: failureMessage
+            });
📝 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: Update Status - Success
if: success()
uses: actions/github-script@v7
with:
script: |
eval(process.env.GET_CONSOLE_LINK);
const prNumber = process.env.PR_NUMBER;
const appUrl = process.env.REVIEW_APP_URL;
const workflowUrl = process.env.WORKFLOW_URL;
const isSuccess = '${{ job.status }}' === 'success';
// Create GitHub deployment status
const deploymentStatus = {
owner: context.repo.owner,
repo: context.repo.repo,
deployment_id: ${{ fromJSON(steps.init-deployment.outputs.result).deploymentId }},
state: isSuccess ? 'success' : 'failure',
environment_url: isSuccess ? appUrl : undefined,
log_url: workflowUrl,
environment: 'review'
};
await github.rest.repos.createDeploymentStatus(deploymentStatus);
// Define messages based on deployment status
const successMessage = [
' Deployment complete for PR #' + prNumber + ', commit ' + '${{ env.COMMIT_HASH }}',
'',
' [Review App for PR #' + prNumber + '](' + appUrl + ')',
'',
' [View Completed Action Build and Deploy Logs](' + workflowUrl + ')',
'✅ Deployment successful!',
'',
getConsoleLink(prNumber)
].join('\n');
const failureMessage = [
' Deployment failed for PR #' + prNumber + ', commit ' + '${{ env.COMMIT_HASH }}',
'🌐 Review app is ready at: ${{ env.REVIEW_APP_URL }}',
'',
' [View Deployment Logs with Errors](' + workflowUrl + ')',
'📝 [View App Logs](' + process.env.WORKFLOW_URL + ')',
'',
getConsoleLink(prNumber)
getConsoleLink(process.env.PR_NUMBER)
].join('\n');
// Update the existing comment
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: process.env.COMMENT_ID,
body: isSuccess ? successMessage : failureMessage
body: successMessage
- name: Update Status - Success
if: success()
uses: actions/github-script@v7
with:
script: |
eval(process.env.GET_CONSOLE_LINK);
const successMessage = [
'✅ Deployment successful!',
'',
'🌐 Review app is ready at: ${{ env.REVIEW_APP_URL }}',
'',
'📝 [View App Logs](' + process.env.WORKFLOW_URL + ')',
'',
getConsoleLink(process.env.PR_NUMBER)
].join('\n');
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: process.env.COMMENT_ID,
body: successMessage
- name: Update Status - Failure
if: failure()
uses: actions/github-script@v7
with:
script: |
eval(process.env.GET_CONSOLE_LINK);
const failureMessage = [
'❌ Deployment failed!',
'',
'📝 [View Error Logs](' + process.env.WORKFLOW_URL + ')',
'',
getConsoleLink(process.env.PR_NUMBER)
].join('\n');
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: process.env.COMMENT_ID,
body: failureMessage
});
🧰 Tools
🪛 yamllint (1.35.1)

[error] 265-265: trailing spaces

(trailing-spaces)

Copy link

github-actions bot commented Jan 26, 2025

🚀 Deploying to Control Plane...

⏳ Waiting for deployment to be ready...

📝 View Deploy Logs

🎮 Control Plane Console

@justin808
Copy link
Member Author

/help

Copy link

github-actions bot commented Jan 26, 2025

@justin808
Copy link
Member Author

/help

Copy link

Available Commands

/deploy-review-app

Deploys your PR branch to a review environment on Control Plane.

  • Creates a new review app if one doesn't exist
  • Updates the existing review app if it already exists
  • Provides a unique URL to preview your changes
  • Shows build and deployment progress in real-time

/delete-review-app

Deletes the review app associated with this PR.

  • Removes all resources from Control Plane
  • Helpful for cleaning up when you're done testing
  • Can be re-deployed later using /deploy-review-app

/help

Shows this help message explaining available commands.


Note: These commands only work in pull request comments.

Copy link

github-actions bot commented Jan 26, 2025

🚀 Deploying to Control Plane...

⏳ Waiting for deployment to be ready...

📝 View Deploy Logs

🎮 Control Plane Console

Copy link

github-actions bot commented Jan 26, 2025

✅ Deployment successful!

🌐 Review app is ready at:

📝 View App Logs

Control Plane Console for Review App with PR #618

Copy link

github-actions bot commented Jan 26, 2025

🚀 Deploying to Control Plane...

⏳ Waiting for deployment to be ready...

📝 View Deploy Logs

🎮 Control Plane Console

@justin808
Copy link
Member Author

/help

Copy link

Available Commands

/deploy-review-app

Deploys your PR branch to a review environment on Control Plane.

  • Creates a new review app if one doesn't exist
  • Updates the existing review app if it already exists
  • Provides a unique URL to preview your changes
  • Shows build and deployment progress in real-time

/delete-review-app

Deletes the review app associated with this PR.

  • Removes all resources from Control Plane
  • Helpful for cleaning up when you're done testing
  • Can be re-deployed later using /deploy-review-app

/help

Shows this help message explaining available commands.


Note: These commands only work in pull request comments.

@justin808 justin808 merged commit 151c527 into master Jan 26, 2025
4 checks passed
@justin808 justin808 deleted the justin808-testing-2025-01-03 branch January 26, 2025 11:35
Copy link

github-actions bot commented Jan 26, 2025

❌ Review app for PR #618 failed to be deleted

View Delete Logs with Errors

🎮 Control Plane Console

Copy link

github-actions bot commented Jan 26, 2025

✅ Deployment successful!

🌐 Review app is ready at:

📝 View App Logs

Control Plane Console for Review App with PR #618

justin808 added a commit that referenced this pull request Jan 28, 2025
* master:
  Enhance GitHub Actions workflows with new features and improvements (#618)
  Enhance GitHub Actions workflows for pull request and issue management (#617)
  Improvements to deployments (#615)
Judahmeek added a commit that referenced this pull request Mar 18, 2025
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