-
Notifications
You must be signed in to change notification settings - Fork 384
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
Revert all recent changes #627
Conversation
WalkthroughThis update modifies various GitHub Actions, workflows, and scripts to streamline CI/CD operations for a Control Plane environment. Changes include renaming application aliases, updating required input parameters, rewriting deployment and deletion logic, adding new scripts for commit SHA retrieval and controlled app deletion, and simplifying help and debug workflows. Several older workflows and actions have been removed or consolidated to reduce complexity while ensuring that deployments, review app creation, and deletions are handled consistently. Changes
Sequence Diagram(s)Deploy Review App FlowsequenceDiagram
participant User as GitHub User
participant PR as Pull Request
participant Workflow as Deploy-to-Control-Plane Workflow
participant Runner as GitHub Runner
participant Env as Setup Environment Action
participant CP as cpflow CLI
User->>PR: Posts '/deploy' comment
PR->>Workflow: Triggers deployment workflow
Workflow->>Runner: Start Process-Deployment-Command job
Runner->>Env: Set up environment & retrieve commit SHA
Env-->>Runner: Return configured environment
Runner->>CP: Execute "cpflow deploy-image" command
CP-->>Runner: Return deployment output (Rails URL)
Runner->>PR: Update pull request comment with deployment status
Delete Review App FlowsequenceDiagram
participant User as GitHub User
participant PR as Pull Request
participant Workflow as Delete Review App Workflow
participant Runner as GitHub Runner
participant DeleteAction as Delete-Control-Plane-App Action
participant CP as cpflow CLI
User->>PR: Posts '/delete-review-app' comment
PR->>Workflow: Triggers deletion workflow
Workflow->>Runner: Start Process-Delete-Command job
Runner->>DeleteAction: Invoke deletion action (runs delete-app.sh)
DeleteAction->>CP: Check app existence & execute "cpflow delete --force"
CP-->>DeleteAction: Return deletion status
DeleteAction-->>Runner: Report deletion result
Runner->>PR: Post deletion status update on pull request
Poem
Tip ⚡🧪 Multi-step agentic review comment chat (experimental)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Hi 👋 To deploy a review app, please comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
🔭 Outside diff range comments (6)
.controlplane/controlplane.yml (1)
41-50
:⚠️ Potential issueRevert Production App Configuration Changes
The production application definition has been modified by renaming the app from “react-webpack-rails-tutorial-production” to “react-webpack-rails-tutorial” and updating the organization value from “shakacode-open-source-examples-staging” to “shakacode-open-source-examples”. Since the PR objective is to revert all recent changes, please restore both the application name and organization settings to their previous values..github/actions/deploy-to-control-plane/scripts/get-commit-sha.sh (1)
1-35
:⚠️ Potential issueRemove Newly Added Commit SHA Script
This file is a newly introduced script for retrieving the commit SHA during deployments. Under the “revert” objective, this new functionality should be removed so that the repository returns to its prior state..github/workflows/help-command.yml (1)
29-91
: 💡 Verification agent❓ Verification inconclusive
Revert Help Command Job Changes
The replacement of the “help” job with “show-help” and the adjustments to the help message are also part of the recent changes. Under the revert objective, please restore the original “help” job configuration and its steps.
Revert Help Command Job Changes
Please restore the original “help” job configuration in .github/workflows/help-command.yml. Currently, the job has been renamed to “show-help” and its help message has been adjusted. Under the revert objective, kindly:
- Rename the job back from “show-help” to “help”.
- Reinstate the original steps and help message as they were prior to these changes.
🧰 Tools
🪛 YAMLlint (1.35.1)
[error] 32-32: trailing spaces
(trailing-spaces)
[error] 33-33: trailing spaces
(trailing-spaces)
[error] 84-84: trailing spaces
(trailing-spaces)
.github/actions/deploy-to-control-plane/action.yml (1)
40-92
: 💡 Verification agent🧩 Analysis chain
Revert Deployment Action Modifications
The deployment steps (including capturing deployment output, extracting the Rails URL, and the waiting logic with timeout) have been modified. Please revert these changes so that the action returns to its previous state, including the original error handling and output assignments.
Below is a shell script that searches for key terms in the deployment action file. We'll use it to verify that the modifications (such as capturing the output, extracting the Rails URL, and the timeout logic) are indeed present in the current version of the file.
Please run this script and review its output. Based on the findings, we can then decide if the modifications should be reverted as suggested.
🏁 Script executed:
#!/bin/bash # Check for usage of the "cpflow deploy-image" command, which is part of the new deployment process. echo "Searching for 'cpflow deploy-image' in .github/actions/deploy-to-control-plane/action.yml" rg -n "cpflow deploy-image" .github/actions/deploy-to-control-plane/action.yml # Check for the usage of TEMP_OUTPUT variable for capturing output. echo "Searching for 'TEMP_OUTPUT' in .github/actions/deploy-to-control-plane/action.yml" rg -n "TEMP_OUTPUT" .github/actions/deploy-to-control-plane/action.yml # Check for the extraction of the Rails URL via grep. echo "Searching for the Rails URL extraction logic via grep in .github/actions/deploy-to-control-plane/action.yml" rg -n "grep -oP 'https://rails-" .github/actions/deploy-to-control-plane/action.yml # Check for the timeout logic in waiting for workloads. echo "Searching for timeout handling in .github/actions/deploy-to-control-plane/action.yml" rg -n "timeout" .github/actions/deploy-to-control-plane/action.yml echo "Search finished."Length of output: 2526
Action Required: Revert Deployment Action Modifications
The file
.github/actions/deploy-to-control-plane/action.yml
(lines 40–92) now includes modifications that differ from its previous behavior. Specifically:
- Output Capture: The new code creates a temporary file (
TEMP_OUTPUT
) to capture deployment logs.- Rails URL Extraction: The app URL is extracted using
grep -oP 'https://rails-[^[:space:]]*\.cpln\.app(?=\s|$)'
, which diverges from the original error handling.- Timeout and Wait Logic: A timeout mechanism has been added to wait for workloads to be ready, deviating from the previous implementation.
Please revert these changes so that the action returns to its original state with its former error handling and output assignments.
🧰 Tools
🪛 YAMLlint (1.35.1)
[error] 45-45: trailing spaces
(trailing-spaces)
[error] 49-49: trailing spaces
(trailing-spaces)
[error] 57-57: trailing spaces
(trailing-spaces)
[error] 66-66: trailing spaces
(trailing-spaces)
[error] 74-74: trailing spaces
(trailing-spaces)
[error] 87-87: trailing spaces
(trailing-spaces)
.github/workflows/delete-review-app.yml (1)
1-110
:⚠️ Potential issueRevert Intent – Restore Previous Delete Workflow
This workflow file has been significantly modified to streamline review app deletions. In line with the PR objective of reverting all recent changes, the modifications—such as the environment variable updates, the renaming of steps (e.g. “init-delete”), and the simplified messaging—should be undone so that the prior, stable configuration is restored. Also, take note of the trailing whitespace issues reported by YAMLlint on lines 40, 41, 56, and 103.
- name: Delete Review App - - on: - issue_comment: - types: [created] - - permissions: - contents: read - deployments: write - pull-requests: write - issues: write - - env: - CPLN_ORG: ${{ secrets.CPLN_ORG }} - CPLN_TOKEN: ${{ secrets.CPLN_TOKEN }} - APP_NAME: qa-react-webpack-rails-tutorial-pr-${{ github.event.issue.number }} - PR_NUMBER: ${{ github.event.issue.number }} - - jobs: - debug-trigger: - if: always() - runs-on: ubuntu-latest - steps: - - name: Debug Trigger Conditions - env: - EVENT_NAME: ${{ github.event_name }} - IS_PR: ${{ toJSON(github.event.issue.pull_request) }} - COMMENT: ${{ github.event.comment.body }} - run: | - echo "Debug information for delete-review-app command:" - echo "Event name: $EVENT_NAME" - echo "Is PR (raw): $IS_PR" - echo "Comment body: $COMMENT" - echo "Raw event payload:" - echo '${{ toJSON(github.event) }}' - - Process-Delete-Command: - needs: debug-trigger - if: | - github.event_name == 'issue_comment' && - github.event.issue.pull_request && - github.event.comment.body == '/delete-review-app' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Validate Required Secrets - 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 - fi - - - name: Setup Environment - uses: ./.github/actions/setup-environment - - - name: Create Initial Delete Comment - id: init-delete - uses: actions/github-script@v7 - with: - script: | - const comment = await github.rest.issues.createComment({ - issue_number: process.env.PR_NUMBER, - owner: context.repo.owner, - repo: context.repo.repo, - body: ' Starting app deletion...' - }); - return { commentId: comment.data.id }; - - - name: Delete Review App - uses: ./.github/actions/delete-control-plane-app - with: - app_name: ${{ env.APP_NAME }} - org: ${{ env.CPLN_ORG }} - github_token: ${{ secrets.GITHUB_TOKEN }} - env: - CPLN_TOKEN: ${{ secrets.CPLN_TOKEN }} - - - name: Update Delete Status - if: always() - uses: actions/github-script@v7 - with: - script: | - const success = '${{ job.status }}' === 'success'; - const prNumber = process.env.PR_NUMBER; - const cpConsoleUrl = `https://console.cpln.io/org/${process.env.CPLN_ORG}/workloads/${process.env.APP_NAME}`; - - const message = success - ? ' Review app for PR #' + prNumber + ' was successfully deleted' - : [ - ' Review app for PR #' + prNumber + ' failed to be deleted', - '', - '[Control Plane Console for Review App with PR #' + prNumber + '](' + cpConsoleUrl + ')' - ].join('\n'); - - await github.rest.issues.updateComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: ${{ fromJSON(steps.init-delete.outputs.result).commentId }}, - body: message - });If reverting recent changes is the goal, please restore this file to its previous contents.
🧰 Tools
🪛 actionlint (1.7.4)
83-83: input "github_token" is not defined in action "Delete Control Plane App" defined at "./.github/actions/delete-control-plane-app". available inputs are "app_name", "org"
(action)
🪛 YAMLlint (1.35.1)
[error] 40-40: trailing spaces
(trailing-spaces)
[error] 41-41: trailing spaces
(trailing-spaces)
[error] 56-56: trailing spaces
(trailing-spaces)
[error] 95-95: trailing spaces
(trailing-spaces)
[error] 103-103: trailing spaces
(trailing-spaces)
.github/workflows/deploy-to-control-plane-staging.yml (1)
1-33
:⚠️ Potential issueRevert Intent – Restore Original Staging Deployment Workflow
This file now deploys the “Main Branch to Control Plane Staging” with several modifications (e.g. branch trigger change, new environment variable usage, and removal of concurrency and environment setup steps). Moreover, according to the static analysis, there is now a missing required input ("github_token") for the deploy action, which can cause deployment failures. In line with the PR objective to revert recent changes, this file should be reverted to its former state.
- name: Deploy Main Branch to Control Plane Staging + name: Deploy to Control Plane Staging - push: - branches: [master] + push: - branches: [master] + branches: ['*'] # (or the original branch specification) - # Environment variables remapped - env: - CPLN_ORG: ${{secrets.CPLN_ORG_STAGING}} - CPLN_TOKEN: ${{secrets.CPLN_TOKEN_STAGING}} + env: + CPLN_ORG: ${{ secrets.CPLN_ORG }} + CPLN_TOKEN: ${{ secrets.CPLN_TOKEN }} - jobs: - deploy-to-control-plane-staging: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: master - - uses: ./.github/actions/deploy-to-control-plane - with: - app_name: ${{ secrets.APP_NAME_STAGING }} - org: ${{ secrets.CPLN_ORG_STAGING }} + # (Revert the above to the previously working configuration, including ensuring all required inputs—like github_token—are provided)Please revert the changes so that the deployment to staging regains its original configuration.
🧰 Tools
🪛 actionlint (1.7.4)
29-29: missing input "github_token" which is required by action "Deploy to Control Plane" defined at "./.github/actions/deploy-to-control-plane". all required inputs are "app_name", "github_token", "org"
(action)
🧹 Nitpick comments (9)
.github/actions/delete-control-plane-app/action.yml (1)
1-21
: Revert Newly Added GitHub Action?
This file introduces a new GitHub Action ("Delete Control Plane App") for deleting a Control Plane application. Given that the overall PR objective is to revert all recent changes, please confirm whether this new action should be removed entirely to restore the previous state..github/actions/setup-environment/action.yml (2)
17-21
: Revert Input-to-Environment Variable Changes
The setup script now installs a downgraded Control Plane CLI version and replaces required inputs (token
andorg
) with environment variable checks. Since the PR objective is to revert all recent changes, please verify if these modifications should be undone to reinstate the original input-based configuration.
25-32
: Address Trailing Spaces Detected by YAMLlint
Static analysis reported trailing spaces on some lines (e.g., around lines 29, 34, and 38). If these changes remain after the reversion, please remove the extraneous spaces to adhere to YAML formatting guidelines.🧰 Tools
🪛 YAMLlint (1.35.1)
[error] 29-29: trailing spaces
(trailing-spaces)
.github/workflows/add-comment-on-pr-creation.yml (1)
1-21
: Revert Workflow Name and Job Changes?
The workflow now uses the name "Add helper Comment on PR creation" with an updated job name ("comment-on-pr") and simplified instructions for adding comments. Since the PR objective is to revert all recent changes, please confirm if this workflow should return to its previous configuration..github/actions/deploy-to-control-plane/scripts/delete-app.sh (1)
1-37
: Revert Newly Added Deletion Script?
This script provides functionality to delete a Control Plane application safely. As it is a newly added file and the PR aims to revert recent changes, please verify whether this file should be removed to restore the prior state..github/actions/build-docker-image/action.yml (2)
14-17
: Revert PR_NUMBER Input Requirement Change
The PR_NUMBER parameter has been made mandatory (line 16). Under the current objective to revert all recent changes, confirm if this input requirement should be reverted to its previous optional status.
25-31
: Remove Trailing Space in Echo Statement
A trailing space was detected (e.g., on line 26) as per YAMLlint. Please remove the extraneous space if this change persists after reverting the recent modifications.🧰 Tools
🪛 YAMLlint (1.35.1)
[error] 26-26: trailing spaces
(trailing-spaces)
.github/workflows/help-command.yml (1)
32-33
: Address Trailing Spaces
Static analysis has flagged trailing spaces on these lines. As part of the revert, please ensure that the original formatting (without trailing spaces) is restored.Also applies to: 84-84
🧰 Tools
🪛 YAMLlint (1.35.1)
[error] 32-32: trailing spaces
(trailing-spaces)
[error] 33-33: trailing spaces
(trailing-spaces)
.github/actions/deploy-to-control-plane/action.yml (1)
45-45
: Remove Trailing Spaces
Static analysis indicates trailing spaces at the marked lines. When reverting, please ensure that the formatting complies with guidelines (i.e. no trailing spaces).Also applies to: 49-49, 57-57, 66-66, 74-74, 87-87
🧰 Tools
🪛 YAMLlint (1.35.1)
[error] 45-45: trailing spaces
(trailing-spaces)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (18)
.controlplane/controlplane.yml
(1 hunks).github/actions/build-docker-image/action.yml
(2 hunks).github/actions/delete-control-plane-app/action.yml
(1 hunks).github/actions/deploy-to-control-plane/action.yml
(1 hunks).github/actions/deploy-to-control-plane/scripts/delete-app.sh
(1 hunks).github/actions/deploy-to-control-plane/scripts/deploy.sh
(3 hunks).github/actions/deploy-to-control-plane/scripts/get-commit-sha.sh
(1 hunks).github/actions/setup-environment/action.yml
(1 hunks).github/actions/validate-required-vars/action.yml
(0 hunks).github/readme.md
(0 hunks).github/workflows/add-comment-on-pr-creation.yml
(1 hunks).github/workflows/debug-workflow.yml
(0 hunks).github/workflows/delete-review-app.yml
(2 hunks).github/workflows/deploy-to-control-plane-review-app.yml
(0 hunks).github/workflows/deploy-to-control-plane-staging.yml
(1 hunks).github/workflows/deploy-to-control-plane.yml
(1 hunks).github/workflows/help-command.yml
(1 hunks).github/workflows/review-app-help.yml
(0 hunks)
💤 Files with no reviewable changes (5)
- .github/actions/validate-required-vars/action.yml
- .github/readme.md
- .github/workflows/deploy-to-control-plane-review-app.yml
- .github/workflows/review-app-help.yml
- .github/workflows/debug-workflow.yml
🧰 Additional context used
🪛 YAMLlint (1.35.1)
.github/actions/setup-environment/action.yml
[error] 29-29: trailing spaces
(trailing-spaces)
[error] 34-34: trailing spaces
(trailing-spaces)
[error] 38-38: trailing spaces
(trailing-spaces)
.github/actions/build-docker-image/action.yml
[error] 26-26: trailing spaces
(trailing-spaces)
.github/workflows/deploy-to-control-plane.yml
[error] 26-26: trailing spaces
(trailing-spaces)
[error] 27-27: trailing spaces
(trailing-spaces)
[error] 61-61: trailing spaces
(trailing-spaces)
[error] 77-77: trailing spaces
(trailing-spaces)
[error] 96-96: trailing spaces
(trailing-spaces)
[error] 99-99: trailing spaces
(trailing-spaces)
[error] 104-104: trailing spaces
(trailing-spaces)
[error] 107-107: trailing spaces
(trailing-spaces)
[error] 115-115: trailing spaces
(trailing-spaces)
[error] 127-127: trailing spaces
(trailing-spaces)
[error] 157-157: trailing spaces
(trailing-spaces)
[error] 188-188: trailing spaces
(trailing-spaces)
[error] 214-214: trailing spaces
(trailing-spaces)
[error] 225-225: trailing spaces
(trailing-spaces)
[error] 227-227: trailing spaces
(trailing-spaces)
[error] 238-238: trailing spaces
(trailing-spaces)
[error] 246-246: trailing spaces
(trailing-spaces)
[error] 275-275: trailing spaces
(trailing-spaces)
[error] 276-276: trailing spaces
(trailing-spaces)
[error] 307-307: trailing spaces
(trailing-spaces)
[error] 335-335: trailing spaces
(trailing-spaces)
[error] 336-336: trailing spaces
(trailing-spaces)
[error] 351-351: trailing spaces
(trailing-spaces)
[error] 390-390: trailing spaces
(trailing-spaces)
[error] 398-398: trailing spaces
(trailing-spaces)
[error] 404-404: no new line character at the end of file
(new-line-at-end-of-file)
.github/actions/deploy-to-control-plane/action.yml
[error] 45-45: trailing spaces
(trailing-spaces)
[error] 49-49: trailing spaces
(trailing-spaces)
[error] 57-57: trailing spaces
(trailing-spaces)
[error] 66-66: trailing spaces
(trailing-spaces)
[error] 74-74: trailing spaces
(trailing-spaces)
[error] 87-87: trailing spaces
(trailing-spaces)
.github/workflows/help-command.yml
[error] 32-32: trailing spaces
(trailing-spaces)
[error] 33-33: trailing spaces
(trailing-spaces)
[error] 84-84: trailing spaces
(trailing-spaces)
.github/workflows/delete-review-app.yml
[error] 40-40: trailing spaces
(trailing-spaces)
[error] 41-41: trailing spaces
(trailing-spaces)
[error] 56-56: trailing spaces
(trailing-spaces)
[error] 103-103: trailing spaces
(trailing-spaces)
🪛 actionlint (1.7.4)
.github/workflows/deploy-to-control-plane.yml
40-40: shellcheck reported issue in this script: SC2086:info:2:22: Double quote to prevent globbing and word splitting
(shellcheck)
40-40: shellcheck reported issue in this script: SC2086:info:3:60: Double quote to prevent globbing and word splitting
(shellcheck)
40-40: shellcheck reported issue in this script: SC2086:info:4:59: Double quote to prevent globbing and word splitting
(shellcheck)
135-135: shellcheck reported issue in this script: SC2086:info:1:86: Double quote to prevent globbing and word splitting
(shellcheck)
135-135: shellcheck reported issue in this script: SC2086:info:2:90: Double quote to prevent globbing and word splitting
(shellcheck)
140-140: shellcheck reported issue in this script: SC2086:info:2:42: Double quote to prevent globbing and word splitting
(shellcheck)
378-378: input "github_token" is not defined in action "Delete Control Plane App" defined at "./.github/actions/delete-control-plane-app". available inputs are "app_name", "org"
(action)
.github/workflows/deploy-to-control-plane-staging.yml
29-29: missing input "github_token" which is required by action "Deploy to Control Plane" defined at "./.github/actions/deploy-to-control-plane". all required inputs are "app_name", "github_token", "org"
(action)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: test (22.x, 3.3.4)
echo "🚀 Deploying to Control Plane (timeout: ${WAIT_TIMEOUT}s)" | ||
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" | ||
echo "Full output:" | ||
cat "$TEMP_OUTPUT" | ||
exit 1 | ||
fi | ||
|
||
# Extract app URL from deployment output | ||
APP_URL=$(grep -oP 'https://[^[:space:]]*\.cpln\.app(?=\s|$)' "$TEMP_OUTPUT" | head -n1) | ||
if [ -z "$APP_URL" ]; then | ||
echo "❌ Error: Could not find app URL in deployment output" | ||
exit 1 | ||
if timeout "$WAIT_TIMEOUT" cpflow deploy-image -a "$APP_NAME" --run-release-phase --org "$CPLN_ORG" --verbose | tee "$TEMP_OUTPUT"; then | ||
# Extract Rails URL from deployment output | ||
RAILS_URL=$(grep -oP 'https://rails-[^[:space:]]*\.cpln\.app(?=\s|$)' "$TEMP_OUTPUT" | head -n1) | ||
if [ -n "$RAILS_URL" ]; then | ||
echo "rails_url=$RAILS_URL" >> "$GITHUB_OUTPUT" | ||
echo "✅ Deployment successful" | ||
echo "🚀 Rails URL: $RAILS_URL" | ||
else | ||
echo "❌ Failed to extract Rails URL from deployment output" | ||
exit 1 | ||
fi | ||
elif [ $? -eq 124 ]; then | ||
echo "❌ Deployment timed out after $WAIT_TIMEOUT seconds" | ||
exit 1 | ||
else | ||
echo "❌ Deployment to Control Plane failed" | ||
exit 1 | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Revert Deployment Logic Changes
The deployment script now implements updated logic for extracting the Rails URL (using a modified regex and dedicated timeout handling). As the PR objective is to revert recent changes, please restore the original deployment logic and error handling. In other words, undo the changes that introduced the Rails-specific URL extraction and the modified “timeout” handling.
I'll start by verifying whether the updated Rails URL extraction logic is present in the deployment script. This will confirm that the new changes (and thus the revert request) are indeed applied. Here’s a shell script to check for the regex used to extract the Rails URL:
Once the results confirm that the extraction logic using the modified regex is present in the file, you can be sure that the deployment script includes the changes that the PR is intended to revert.
🏁 Script executed:
#!/bin/bash
# Verify if the updated Rails URL extraction logic is present in the deployment script.
grep -n "grep -oP 'https://rails-[^[:space:]]*\.cpln\.app(?=\\s|$)'" .github/actions/deploy-to-control-plane/scripts/deploy.sh
Length of output: 255
Below is a revised review comment. Since the initial search for the modified Rails URL extraction logic did not return any output, I'm asking for manual re‑verification to confirm whether the new code is present or if the changes have already been reverted.
Action Required:
- Verify manually: Please inspect
.github/actions/deploy-to-control-plane/scripts/deploy.sh
to confirm whether the new Rails URL extraction logic (i.e. the modifiedgrep -oP
regex) and updated timeout handling are still present. - Revert if necessary: If these changes are detected, revert them so that the script restores the original deployment logic and error handling, per the PR objective.
🏁 Script executed:
#!/bin/bash
echo "Searching for updated Rails URL extraction logic in deploy.sh..."
rg "grep -oP 'https://rails-[^[:space:]]*\.cpln\.app(?=\\s|$)'" .github/actions/deploy-to-control-plane/scripts/deploy.sh
echo "Searching for the cpflow deploy-image and timeout handling block..."
rg "timeout .* cpflow deploy-image" .github/actions/deploy-to-control-plane/scripts/deploy.sh
Length of output: 1076
Action Required: Revert Updated Deployment Logic Changes
Our investigation indicates that the deployment script still contains the updated logic for timeout handling—as evidenced by the presence of the cpflow deploy-image command wrapped with the timeout—and likely retains the new Rails URL extraction via the modified grep command (despite regex tool limitations affecting our automated search). Please review the file at .github/actions/deploy-to-control-plane/scripts/deploy.sh (lines 33–51) and revert the following changes:
- Rails URL Extraction: Undo the changes that replace the original URL extraction logic with the modified regex using
grep -oP 'https://rails-[^[:space:]]*\.cpln\.app(?=\s|$)'
. - Timeout Handling: Restore the previous timeout handling behavior by removing the updated cpflow command (with its new flags/options) if it does not conform to the original implementation.
Manual verification is advised to confirm that the updated logic is effectively reverted.
name: Show Help for Commands | ||
|
||
on: | ||
issue_comment: | ||
types: [created] | ||
workflow_dispatch: | ||
inputs: | ||
pr_number: | ||
description: 'Pull Request number to post help comment on' | ||
required: true | ||
type: string | ||
|
||
permissions: | ||
issues: write | ||
pull-requests: write | ||
|
||
jobs: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert Workflow Name and Trigger Changes
The workflow name has been changed from “Help Command” to “Show Help for Commands” and its trigger/permissions section has been updated. Please revert these modifications so that the workflow name and basic trigger settings match the original configuration.
debug-trigger: | ||
if: always() | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Debug Trigger Conditions | ||
env: | ||
EVENT_NAME: ${{ github.event_name }} | ||
IS_PR: ${{ toJSON(github.event.issue.pull_request) }} | ||
COMMENT: ${{ github.event.comment.body }} | ||
run: | | ||
echo "Debug information for help command:" | ||
echo "Event name: $EVENT_NAME" | ||
echo "Is PR (raw): $IS_PR" | ||
echo "Comment body: $COMMENT" | ||
echo "Raw event payload:" | ||
echo '${{ toJSON(github.event) }}' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Remove Debug-Trigger Job
A new job (“debug-trigger”) has been added to output event debug information. As this falls under the recent changes, please remove the added debug-trigger job and revert to the original single-job configuration used for help commands.
- name: Setup Environment | ||
uses: ./.github/actions/setup-environment | ||
|
||
- name: Get Commit SHA | ||
id: get_sha | ||
shell: bash | ||
run: ${{ github.action_path }}/scripts/get-commit-sha.sh | ||
env: | ||
GITHUB_TOKEN: ${{ inputs.github_token }} | ||
PR_NUMBER: ${{ env.PR_NUMBER }} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert Added Environment Setup and Commit SHA Steps
Additional steps have been added for setting up the environment and retrieving the commit SHA (via get-commit-sha.sh). As the intent is to revert recent changes, remove these steps and restore the original inputs and workflow logic.
'_Note: These commands only work in pull request comments._' | ||
].join('\n'); | ||
|
||
await github.rest.issues.createComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.payload.issue.number, | ||
body: helpMessage | ||
}); | ||
|
||
debug-delete: | ||
if: always() | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Debug Trigger Conditions | ||
env: | ||
EVENT_NAME: ${{ github.event_name }} | ||
IS_PR: ${{ toJSON(github.event.issue.pull_request) }} | ||
COMMENT: ${{ github.event.comment.body }} | ||
run: | | ||
echo "Debug information for delete-review-app command:" | ||
echo "Event name: $EVENT_NAME" | ||
echo "Is PR (raw): $IS_PR" | ||
echo "Comment body: $COMMENT" | ||
echo "Raw event payload:" | ||
echo '${{ toJSON(github.event) }}' | ||
|
||
Process-Delete-Command: | ||
needs: debug-delete | ||
if: | | ||
github.event_name == 'issue_comment' && | ||
github.event.issue.pull_request && | ||
github.event.comment.body == '/delete-review-app' | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Validate Required Secrets | ||
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 | ||
fi | ||
|
||
- name: Setup Environment | ||
uses: ./.github/actions/setup-environment | ||
|
||
- name: Create Initial Delete Comment | ||
id: init-delete | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
const comment = await github.rest.issues.createComment({ | ||
issue_number: process.env.PR_NUMBER, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: ' Starting app deletion...' | ||
}); | ||
return { commentId: comment.data.id }; | ||
|
||
- name: Delete Review App | ||
uses: ./.github/actions/delete-control-plane-app | ||
with: | ||
app_name: ${{ env.APP_NAME }} | ||
org: ${{ env.CPLN_ORG }} | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
env: | ||
CPLN_TOKEN: ${{ secrets.CPLN_TOKEN }} | ||
|
||
- name: Update Delete Status | ||
if: always() | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
const success = '${{ job.status }}' === 'success'; | ||
const prNumber = process.env.PR_NUMBER; | ||
const cpConsoleUrl = `https://console.cpln.io/org/${process.env.CPLN_ORG}/workloads/${process.env.APP_NAME}`; | ||
|
||
const message = success | ||
? ' Review app for PR #' + prNumber + ' was successfully deleted' | ||
: [ | ||
' Review app for PR #' + prNumber + ' failed to be deleted', | ||
'', | ||
' [Control Plane Console for Review App with PR #' + prNumber + '](' + cpConsoleUrl + ')' | ||
].join('\n'); | ||
|
||
await github.rest.issues.updateComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
comment_id: ${{ fromJSON(steps.init-delete.outputs.result).commentId }}, | ||
body: message | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert Intent – Remove or Restore This Workflow
The entire workflow “Deploy Review App to Control Plane” is a recent addition that radically changes the CI/CD deployment process. Since the PR objective is to revert all recent changes, this file should be removed (or fully restored to its previous version) rather than merged as is. Additionally, note that there are several formatting issues (e.g. trailing spaces) and shell quoting warnings (e.g. in the run steps) flagged by static analysis. These issues would be resolved naturally if you revert to the prior stable state.
- name: Deploy Review App to Control Plane
-
- run-name: ${{ (github.event_name == 'pull_request' || (github.event_name == 'issue_comment' && github.event.issue.pull_request)) && 'Deploying Review App' || format('Deploying {0} to Staging App', github.ref_name) }}
-
- on:
- pull_request:
- types: [opened, synchronize, reopened]
- issue_comment:
- types: [created]
-
- # Use concurrency to cancel in-progress runs
- concurrency:
- group: deploy-${{ github.event.pull_request.number || github.event.issue.number }}
- cancel-in-progress: true
-
- env:
- APP_NAME: qa-react-webpack-rails-tutorial-pr-${{ github.event.pull_request.number || github.event.issue.number }}
- CPLN_ORG: ${{ secrets.CPLN_ORG }}
- CPLN_TOKEN: ${{ secrets.CPLN_TOKEN }}
- PR_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }}
-
- jobs:
- Process-Deployment-Command:
- if: |
- (github.event_name == 'pull_request') ||
- (github.event_name == 'issue_comment' &&
- github.event.issue.pull_request &&
- github.event.comment.body == '/deploy')
- runs-on: ubuntu-latest
- permissions:
- contents: read
- deployments: write
- pull-requests: write
- issues: write
-
- steps:
- - name: Get PR HEAD Ref
- if: github.event_name == 'issue_comment'
- id: getRef
- run: |
- # For PR comments, get the actual PR head commit
- PR_DATA=$(gh pr view $PR_NUMBER --repo ${{ github.repository }} --json headRefName,headRefOid)
- echo "PR_REF=$(echo "$PR_DATA" | jq -r '.headRefName')" >> $GITHUB_OUTPUT
- echo "PR_SHA=$(echo "$PR_DATA" | jq -r '.headRefOid')" >> $GITHUB_OUTPUT
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
- - uses: actions/checkout@v4
- with:
- fetch-depth: 0
- ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || steps.getRef.outputs.PR_REF || github.ref }}
-
- - name: Validate Required Secrets
- 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
- fi
-
- - name: Setup Environment
- uses: ./.github/actions/setup-environment
-
- - name: Set shared functions
- id: shared-functions
- uses: actions/github-script@v7
- with:
- script: |
- core.exportVariable('GET_CONSOLE_LINK', `
- function getConsoleLink(prNumber) {
- return ' [Control Plane Console for Review App with PR #' + prNumber + '](' +
- 'https://console.cpln.io/org/' + process.env.CPLN_ORG + '/workloads/' + process.env.APP_NAME + ')';
- }
- `);
-
- - name: Initialize Deployment
- id: init-deployment
- uses: actions/github-script@v7
- with:
- script: |
- eval(process.env.GET_CONSOLE_LINK);
-
- async function getWorkflowUrl(runId) {
- // Get the current job ID
- const jobs = await github.rest.actions.listJobsForWorkflowRun({
- owner: context.repo.owner,
- repo: context.repo.repo,
- run_id: runId
- });
-
- const currentJob = jobs.data.jobs.find(job => job.status === 'in_progress');
- const jobId = currentJob?.id;
-
- if (!jobId) {
- console.log('Warning: Could not find current job ID');
- return `${process.env.GITHUB_SERVER_URL}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
- }
-
- return `${process.env.GITHUB_SERVER_URL}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}/job/${jobId}`;
- }
-
- // Create initial deployment comment
- const comment = await github.rest.issues.createComment({
- owner: context.repo.owner,
- repo: context.repo.repo,
- issue_number: process.env.PR_NUMBER,
- body: ' Initializing deployment...'
- });
-
- // Create GitHub deployment
- 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: []
- });
-
- const workflowUrl = await getWorkflowUrl(context.runId);
-
- return {
- deploymentId: deployment.data.id,
- commentId: comment.data.id,
- workflowUrl
- };
-
- - name: Set comment ID and workflow URL
- run: |
- echo "COMMENT_ID=${{ fromJSON(steps.init-deployment.outputs.result).commentId }}" >> $GITHUB_ENV
- echo "WORKFLOW_URL=${{ fromJSON(steps.init-deployment.outputs.result).workflowUrl }}" >> $GITHUB_ENV
-
- - name: Set commit hash
- run: |
- FULL_COMMIT="${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || steps.getRef.outputs.PR_SHA || github.sha }}"
- echo "COMMIT_HASH=${FULL_COMMIT:0:7}" >> $GITHUB_ENV
-
- - name: Update Status - Building
- uses: actions/github-script@v7
- with:
- script: |
- eval(process.env.GET_CONSOLE_LINK);
-
- const buildingMessage = [
- ' Building Docker image for PR #' + process.env.PR_NUMBER + ', commit ' + '${{ env.COMMIT_HASH }}',
- '',
- ' [View Build 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: buildingMessage
- });
-
- - name: Build Docker Image
- uses: ./.github/actions/build-docker-image
- with:
- app_name: ${{ env.APP_NAME }}
- org: ${{ env.CPLN_ORG }}
- commit: ${{ env.COMMIT_HASH }}
- PR_NUMBER: ${{ env.PR_NUMBER }}
-
- - name: Update Status - Deploying
- uses: actions/github-script@v7
- with:
- script: |
- eval(process.env.GET_CONSOLE_LINK);
-
- const deployingMessage = [
- ' Deploying to Control Plane...',
- '',
- ' Waiting for deployment to be ready...',
- '',
- ' [View Deploy 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: deployingMessage
- });
-
- - name: Deploy to Control Plane
- uses: ./.github/actions/deploy-to-control-plane
- with:
- app_name: ${{ env.APP_NAME }}
- org: ${{ env.CPLN_ORG }}
- github_token: ${{ secrets.GITHUB_TOKEN }}
- wait_timeout: ${{ vars.WAIT_TIMEOUT || 900 }}
-
- - name: Update Status - Deployment Complete
- 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 + ')',
- '',
- getConsoleLink(prNumber)
- ].join('\n');
-
- const failureMessage = [
- ' Deployment failed for PR #' + prNumber + ', commit ' + '${{ env.COMMIT_HASH }}',
- '',
- ' [View Deployment Logs with Errors](' + workflowUrl + ')',
- '',
- getConsoleLink(prNumber)
- ].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
- });
If the intention is truly to "revert all recent changes," then this entire workflow file should not be present in its current form.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
name: Deploy Review App to Control Plane | |
run-name: ${{ (github.event_name == 'pull_request' || (github.event_name == 'issue_comment' && github.event.issue.pull_request)) && 'Deploying Review App' || format('Deploying {0} to Staging App', github.ref_name) }} | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened] | |
issue_comment: | |
types: [created] | |
# Use concurrency to cancel in-progress runs | |
concurrency: | |
group: deploy-${{ github.event.pull_request.number || github.event.issue.number }} | |
cancel-in-progress: true | |
env: | |
APP_NAME: qa-react-webpack-rails-tutorial-pr-${{ github.event.pull_request.number || github.event.issue.number }} | |
CPLN_ORG: ${{ secrets.CPLN_ORG }} | |
CPLN_TOKEN: ${{ secrets.CPLN_TOKEN }} | |
PR_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }} | |
jobs: | |
Process-Deployment-Command: | |
if: | | |
(github.event_name == 'pull_request') || | |
(github.event_name == 'issue_comment' && | |
github.event.issue.pull_request && | |
github.event.comment.body == '/deploy') | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
deployments: write | |
pull-requests: write | |
issues: write | |
steps: | |
- name: Get PR HEAD Ref | |
if: github.event_name == 'issue_comment' | |
id: getRef | |
run: | | |
# For PR comments, get the actual PR head commit | |
PR_DATA=$(gh pr view $PR_NUMBER --repo ${{ github.repository }} --json headRefName,headRefOid) | |
echo "PR_REF=$(echo "$PR_DATA" | jq -r '.headRefName')" >> $GITHUB_OUTPUT | |
echo "PR_SHA=$(echo "$PR_DATA" | jq -r '.headRefOid')" >> $GITHUB_OUTPUT | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || steps.getRef.outputs.PR_REF || github.ref }} | |
- name: Validate Required Secrets | |
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 | |
fi | |
- name: Setup Environment | |
uses: ./.github/actions/setup-environment | |
- name: Set shared functions | |
id: shared-functions | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
core.exportVariable('GET_CONSOLE_LINK', ` | |
function getConsoleLink(prNumber) { | |
return ' [Control Plane Console for Review App with PR #' + prNumber + '](' + | |
'https://console.cpln.io/org/' + process.env.CPLN_ORG + '/workloads/' + process.env.APP_NAME + ')'; | |
} | |
`); | |
- name: Initialize Deployment | |
id: init-deployment | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
eval(process.env.GET_CONSOLE_LINK); | |
async function getWorkflowUrl(runId) { | |
// Get the current job ID | |
const jobs = await github.rest.actions.listJobsForWorkflowRun({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: runId | |
}); | |
const currentJob = jobs.data.jobs.find(job => job.status === 'in_progress'); | |
const jobId = currentJob?.id; | |
if (!jobId) { | |
console.log('Warning: Could not find current job ID'); | |
return `${process.env.GITHUB_SERVER_URL}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`; | |
} | |
return `${process.env.GITHUB_SERVER_URL}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}/job/${jobId}`; | |
} | |
// Create initial deployment comment | |
const comment = await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: process.env.PR_NUMBER, | |
body: ' Initializing deployment...' | |
}); | |
// Create GitHub deployment | |
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: [] | |
}); | |
const workflowUrl = await getWorkflowUrl(context.runId); | |
return { | |
deploymentId: deployment.data.id, | |
commentId: comment.data.id, | |
workflowUrl | |
}; | |
- name: Set comment ID and workflow URL | |
run: | | |
echo "COMMENT_ID=${{ fromJSON(steps.init-deployment.outputs.result).commentId }}" >> $GITHUB_ENV | |
echo "WORKFLOW_URL=${{ fromJSON(steps.init-deployment.outputs.result).workflowUrl }}" >> $GITHUB_ENV | |
- name: Set commit hash | |
run: | | |
FULL_COMMIT="${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || steps.getRef.outputs.PR_SHA || github.sha }}" | |
echo "COMMIT_HASH=${FULL_COMMIT:0:7}" >> $GITHUB_ENV | |
- name: Update Status - Building | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
eval(process.env.GET_CONSOLE_LINK); | |
const buildingMessage = [ | |
' Building Docker image for PR #' + process.env.PR_NUMBER + ', commit ' + '${{ env.COMMIT_HASH }}', | |
'', | |
' [View Build 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: buildingMessage | |
}); | |
- name: Build Docker Image | |
uses: ./.github/actions/build-docker-image | |
with: | |
app_name: ${{ env.APP_NAME }} | |
org: ${{ env.CPLN_ORG }} | |
commit: ${{ env.COMMIT_HASH }} | |
PR_NUMBER: ${{ env.PR_NUMBER }} | |
- name: Update Status - Deploying | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
eval(process.env.GET_CONSOLE_LINK); | |
const deployingMessage = [ | |
' Deploying to Control Plane...', | |
'', | |
' Waiting for deployment to be ready...', | |
'', | |
' [View Deploy 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: deployingMessage | |
}); | |
- name: Deploy to Control Plane | |
uses: ./.github/actions/deploy-to-control-plane | |
with: | |
app_name: ${{ env.APP_NAME }} | |
org: ${{ env.CPLN_ORG }} | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
wait_timeout: ${{ vars.WAIT_TIMEOUT || 900 }} | |
- name: Update Status - Deployment Complete | |
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 + ')', | |
'', | |
getConsoleLink(prNumber) | |
].join('\n'); | |
const failureMessage = [ | |
' Deployment failed for PR #' + prNumber + ', commit ' + '${{ env.COMMIT_HASH }}', | |
'', | |
' [View Deployment Logs with Errors](' + workflowUrl + ')', | |
'', | |
getConsoleLink(prNumber) | |
].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 | |
}); | |
debug-help: | |
if: always() | |
runs-on: ubuntu-latest | |
steps: | |
- name: Debug Trigger Conditions | |
env: | |
EVENT_NAME: ${{ github.event_name }} | |
IS_PR: ${{ toJSON(github.event.issue.pull_request) }} | |
COMMENT: ${{ github.event.comment.body }} | |
run: | | |
echo "Debug information for help command:" | |
echo "Event name: $EVENT_NAME" | |
echo "Is PR (raw): $IS_PR" | |
echo "Comment body: $COMMENT" | |
echo "Raw event payload:" | |
echo '${{ toJSON(github.event) }}' | |
show-help: | |
needs: debug-help | |
if: | | |
github.event_name == 'issue_comment' && | |
github.event.issue.pull_request && | |
github.event.comment.body == '/help' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Show Available Commands | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const helpMessage = [ | |
'## Available Commands', | |
'', | |
'### `/deploy`', | |
'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`', | |
'', | |
'### `/help`', | |
'Shows this help message explaining available commands.', | |
'', | |
'---', | |
'_Note: These commands only work in pull request comments._' | |
].join('\n'); | |
await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.payload.issue.number, | |
body: helpMessage | |
}); | |
debug-delete: | |
if: always() | |
runs-on: ubuntu-latest | |
steps: | |
- name: Debug Trigger Conditions | |
env: | |
EVENT_NAME: ${{ github.event_name }} | |
IS_PR: ${{ toJSON(github.event.issue.pull_request) }} | |
COMMENT: ${{ github.event.comment.body }} | |
run: | | |
echo "Debug information for delete-review-app command:" | |
echo "Event name: $EVENT_NAME" | |
echo "Is PR (raw): $IS_PR" | |
echo "Comment body: $COMMENT" | |
echo "Raw event payload:" | |
echo '${{ toJSON(github.event) }}' | |
Process-Delete-Command: | |
needs: debug-delete | |
if: | | |
github.event_name == 'issue_comment' && | |
github.event.issue.pull_request && | |
github.event.comment.body == '/delete-review-app' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Validate Required Secrets | |
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 | |
fi | |
- name: Setup Environment | |
uses: ./.github/actions/setup-environment | |
- name: Create Initial Delete Comment | |
id: init-delete | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const comment = await github.rest.issues.createComment({ | |
issue_number: process.env.PR_NUMBER, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: ' Starting app deletion...' | |
}); | |
return { commentId: comment.data.id }; | |
- name: Delete Review App | |
uses: ./.github/actions/delete-control-plane-app | |
with: | |
app_name: ${{ env.APP_NAME }} | |
org: ${{ env.CPLN_ORG }} | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
env: | |
CPLN_TOKEN: ${{ secrets.CPLN_TOKEN }} | |
- name: Update Delete Status | |
if: always() | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const success = '${{ job.status }}' === 'success'; | |
const prNumber = process.env.PR_NUMBER; | |
const cpConsoleUrl = `https://console.cpln.io/org/${process.env.CPLN_ORG}/workloads/${process.env.APP_NAME}`; | |
const message = success | |
? ' Review app for PR #' + prNumber + ' was successfully deleted' | |
: [ | |
' Review app for PR #' + prNumber + ' failed to be deleted', | |
'', | |
' [Control Plane Console for Review App with PR #' + prNumber + '](' + cpConsoleUrl + ')' | |
].join('\n'); | |
await github.rest.issues.updateComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
comment_id: ${{ fromJSON(steps.init-delete.outputs.result).commentId }}, | |
body: message | |
}); |
🧰 Tools
🪛 actionlint (1.7.4)
40-40: shellcheck reported issue in this script: SC2086:info:2:22: Double quote to prevent globbing and word splitting
(shellcheck)
40-40: shellcheck reported issue in this script: SC2086:info:3:60: Double quote to prevent globbing and word splitting
(shellcheck)
40-40: shellcheck reported issue in this script: SC2086:info:4:59: Double quote to prevent globbing and word splitting
(shellcheck)
135-135: shellcheck reported issue in this script: SC2086:info:1:86: Double quote to prevent globbing and word splitting
(shellcheck)
135-135: shellcheck reported issue in this script: SC2086:info:2:90: Double quote to prevent globbing and word splitting
(shellcheck)
140-140: shellcheck reported issue in this script: SC2086:info:2:42: Double quote to prevent globbing and word splitting
(shellcheck)
378-378: input "github_token" is not defined in action "Delete Control Plane App" defined at "./.github/actions/delete-control-plane-app". available inputs are "app_name", "org"
(action)
🪛 YAMLlint (1.35.1)
[error] 26-26: trailing spaces
(trailing-spaces)
[error] 27-27: trailing spaces
(trailing-spaces)
[error] 61-61: trailing spaces
(trailing-spaces)
[error] 77-77: trailing spaces
(trailing-spaces)
[error] 96-96: trailing spaces
(trailing-spaces)
[error] 99-99: trailing spaces
(trailing-spaces)
[error] 104-104: trailing spaces
(trailing-spaces)
[error] 107-107: trailing spaces
(trailing-spaces)
[error] 115-115: trailing spaces
(trailing-spaces)
[error] 127-127: trailing spaces
(trailing-spaces)
[error] 157-157: trailing spaces
(trailing-spaces)
[error] 188-188: trailing spaces
(trailing-spaces)
[error] 214-214: trailing spaces
(trailing-spaces)
[error] 225-225: trailing spaces
(trailing-spaces)
[error] 227-227: trailing spaces
(trailing-spaces)
[error] 238-238: trailing spaces
(trailing-spaces)
[error] 246-246: trailing spaces
(trailing-spaces)
[error] 275-275: trailing spaces
(trailing-spaces)
[error] 276-276: trailing spaces
(trailing-spaces)
[error] 307-307: trailing spaces
(trailing-spaces)
[error] 335-335: trailing spaces
(trailing-spaces)
[error] 336-336: trailing spaces
(trailing-spaces)
[error] 351-351: trailing spaces
(trailing-spaces)
[error] 390-390: trailing spaces
(trailing-spaces)
[error] 398-398: trailing spaces
(trailing-spaces)
[error] 404-404: no new line character at the end of file
(new-line-at-end-of-file)
This change is
Summary by CodeRabbit
New Features
Refactor