From ce0b7dd9b42dc1105b0abc810be72d52e1280444 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Mon, 27 Jan 2025 18:41:55 -1000 Subject: [PATCH 1/3] Updated help --- .github/workflows/help-command.yml | 38 ++++++++++++++---------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/.github/workflows/help-command.yml b/.github/workflows/help-command.yml index 90f19a2c..d7374900 100644 --- a/.github/workflows/help-command.yml +++ b/.github/workflows/help-command.yml @@ -46,19 +46,6 @@ jobs: '- Provides a unique URL to preview your changes', '- Shows build and deployment progress in real-time', '', - '**Required Environment Secrets:**', - '- `CPLN_TOKEN_STAGING`: Control Plane authentication token', - '- `CPLN_TOKEN_PRODUCTION`: Control Plane authentication token', - '', - '**Required GitHub Actions Variables:**', - '- `CPLN_ORG_STAGING`: Control Plane authentication token', - '- `CPLN_ORG_PRODUCTION`: Control Plane authentication token', - '', - '**Required GitHub Actions Variables (these need to match your control_plane.yml file:**', - '- `PRODUCTION_APP_NAME`: Control Plane production app name', - '- `STAGING_APP_NAME`: Control Plane staging app name', - '- `REVIEW_APP_PREFIX`: Control Plane review app prefix', - '', '**Optional Configuration:**', '- `WAIT_TIMEOUT`: Deployment timeout in seconds (default: 900)', ' - Must be a positive integer', @@ -81,17 +68,28 @@ jobs: '---', '## Environment Setup', '', - '1. Set required secrets in your repository settings:', - ' - `CPLN_TOKEN`', - ' - `CPLN_ORG`', + '**Required Environment Secrets:**', + '- `CPLN_TOKEN_STAGING`: Control Plane authentication token', + '- `CPLN_TOKEN_PRODUCTION`: Control Plane authentication token', + '', + '**Required GitHub Actions Variables:**', + '- `CPLN_ORG_STAGING`: Control Plane authentication token', + '- `CPLN_ORG_PRODUCTION`: Control Plane authentication token', + '', + '**Required GitHub Actions Variables (these need to match your control_plane.yml file:**', + '- `PRODUCTION_APP_NAME`: Control Plane production app name', + '- `STAGING_APP_NAME`: Control Plane staging app name', + '- `REVIEW_APP_PREFIX`: Control Plane review app prefix', '', - '2. Optional: Configure `WAIT_TIMEOUT` in GitHub Actions variables to customize deployment timeout', + Optional: Configure `WAIT_TIMEOUT` in GitHub Actions variables to customize deployment timeout', '', '## Control Plane Integration', '', - 'Review apps are deployed to Control Plane with the following configuration:', - '- App Name Format: `qa-react-webpack-rails-tutorial-pr-{PR_NUMBER}`', - '- Console URL: `https://console.cpln.io/console/org/{CPLN_ORG}/gvc/{APP_NAME}/-info`', + '1. Review app naming convention:', + ' ```', + ' ${{ vars.REVIEW_APP_PREFIX }}-', + ' ```', + '2. Console URL: `https://console.cpln.io/console/org/{CPLN_ORG}/gvc/{APP_NAME}/-info`', '', '## Automatic Cleanup', '', From 0536f3b6cfb1f310c84d143d058246d56c2b9857 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Mon, 27 Jan 2025 18:58:39 -1000 Subject: [PATCH 2/3] update to current branch for uses --- .github/actions/help-command/action.yml | 93 +++++++++++++++++++ .github/workflows/delete-review-app.yml | 4 +- .../deploy-to-control-plane-staging.yml | 2 +- .github/workflows/deploy-to-control-plane.yml | 6 +- .github/workflows/help-command.yml | 93 +------------------ .../nightly-remove-stale-review-apps.yml | 2 +- .../promote-staging-to-production.yml | 2 +- .github/workflows/review-app-help.yml | 3 +- 8 files changed, 107 insertions(+), 98 deletions(-) create mode 100644 .github/actions/help-command/action.yml diff --git a/.github/actions/help-command/action.yml b/.github/actions/help-command/action.yml new file mode 100644 index 00000000..0e0a1799 --- /dev/null +++ b/.github/actions/help-command/action.yml @@ -0,0 +1,93 @@ +name: 'Show Help Command' +description: 'Displays help information for available commands in PR comments' + +inputs: + github-token: + description: 'GitHub token for posting comments' + required: true + +runs: + using: "composite" + steps: + - name: Show Available Commands + uses: actions/github-script@justin808-more-work-on-review-apps-1 + with: + github-token: ${{ inputs.github-token }} + script: | + const helpText = [ + '# Available Commands', + '', + '## `/deploy`', + '**Purpose:** Deploy a review app for your pull request', + '', + '**What it does:**', + '- Creates a new review app in Control Plane', + '- Deploys your changes to the review environment', + '- Provides a unique URL to preview your changes', + '- Shows build and deployment progress in real-time', + '', + '**Optional Configuration:**', + '- `WAIT_TIMEOUT`: Deployment timeout in seconds (default: 900)', + ' - Must be a positive integer', + ' - Example: `/deploy timeout=1800`', + '', + '## `/destroy`', + '**Purpose:** Remove the review app for your pull request', + '', + '**What it does:**', + '- Deletes the review app from Control Plane', + '- Cleans up associated resources', + '- Updates PR with deletion status', + '', + '---', + '## Environment Setup', + '', + '**Required Environment Secrets:**', + '- `CPLN_TOKEN_STAGING`: Control Plane authentication token', + '- `CPLN_TOKEN_PRODUCTION`: Control Plane authentication token', + '', + '**Required GitHub Actions Variables:**', + '- `CPLN_ORG_STAGING`: Control Plane authentication token', + '- `CPLN_ORG_PRODUCTION`: Control Plane authentication token', + '', + '**Required GitHub Actions Variables (these need to match your control_plane.yml file:**', + '- `PRODUCTION_APP_NAME`: Control Plane production app name', + '- `STAGING_APP_NAME`: Control Plane staging app name', + '- `REVIEW_APP_PREFIX`: Control Plane review app prefix', + '', + 'Optional: Configure `WAIT_TIMEOUT` in GitHub Actions variables to customize deployment timeout', + '', + '## Control Plane Integration', + '', + '1. Review app naming convention:', + ' ```', + ' ${{ vars.REVIEW_APP_PREFIX }}-', + ' ```', + '2. Console URL: `https://console.cpln.io/console/org/{CPLN_ORG}/gvc/{APP_NAME}/-info`', + '', + '## Automatic Cleanup', + '', + 'Review apps are automatically destroyed when:', + '1. The pull request is closed', + '2. The `/destroy` command is used', + '3. A new deployment is requested (old one is cleaned up first)', + '', + '## Need Help?', + '', + 'For additional assistance:', + '1. Check the [Control Plane documentation](https://docs.controlplane.com/)', + '2. Contact the infrastructure team', + '3. Open an issue in this repository', + ].join('\n'); + + const context = github.context; + if (context.eventName === 'issue_comment') { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.issue.number, + body: helpText + }); + } else { + console.log(helpText); + } diff --git a/.github/workflows/delete-review-app.yml b/.github/workflows/delete-review-app.yml index 3f547579..6a0178ff 100644 --- a/.github/workflows/delete-review-app.yml +++ b/.github/workflows/delete-review-app.yml @@ -58,7 +58,7 @@ jobs: fi - name: Setup Environment - uses: ./.github/actions/setup-environment@justin808-working-for-deploys + uses: ./.github/actions/setup-environment@justin808-more-work-on-review-apps-1 with: org: ${{ env.CPLN_ORG }} token: ${{ env.CPLN_TOKEN }} @@ -132,7 +132,7 @@ jobs: return { commentId: comment.data.id }; - name: Delete Review App - uses: ./.github/actions/delete-control-plane-app@justin808-working-for-deploys + uses: ./.github/actions/delete-control-plane-app@justin808-more-work-on-review-apps-1 with: app_name: ${{ env.APP_NAME }} org: ${{ env.CPLN_ORG }} diff --git a/.github/workflows/deploy-to-control-plane-staging.yml b/.github/workflows/deploy-to-control-plane-staging.yml index b56511b1..1fa6b27c 100644 --- a/.github/workflows/deploy-to-control-plane-staging.yml +++ b/.github/workflows/deploy-to-control-plane-staging.yml @@ -26,7 +26,7 @@ jobs: fetch-depth: 0 # Fetch all history for proper SHA handling ref: master # Explicitly checkout master branch - - uses: ./.github/actions/deploy-to-control-plane@justin808-working-for-deploys + - uses: ./.github/actions/deploy-to-control-plane@justin808-more-work-on-review-apps-1 with: app_name: ${{ vars.STAGING_APP_NAME }} org: ${{ vars.CPLN_ORG_STAGING }} diff --git a/.github/workflows/deploy-to-control-plane.yml b/.github/workflows/deploy-to-control-plane.yml index 35e26082..b921f39c 100644 --- a/.github/workflows/deploy-to-control-plane.yml +++ b/.github/workflows/deploy-to-control-plane.yml @@ -40,7 +40,7 @@ jobs: ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || steps.getRef.outputs.PR_REF || github.ref }} - name: Setup Environment - uses: ./.github/actions/setup-environment@justin808-working-for-deploys + uses: ./.github/actions/setup-environment@justin808-more-work-on-review-apps-1 with: token: ${{ env.CPLN_TOKEN }} org: ${{ env.CPLN_ORG }} @@ -228,7 +228,7 @@ jobs: github.event.issue.pull_request && github.event.comment.body == '/deploy-review-app') || (steps.check-app.outputs.app_exists == 'true') - uses: ./.github/actions/build-docker-image@justin808-working-for-deploys + uses: ./.github/actions/build-docker-image@justin808-more-work-on-review-apps-1 with: app_name: ${{ env.APP_NAME }} org: ${{ env.CPLN_ORG }} @@ -269,7 +269,7 @@ jobs: github.event.issue.pull_request && github.event.comment.body == '/deploy-review-app') || (steps.check-app.outputs.app_exists == 'true') - uses: ./.github/actions/deploy-to-control-plane@justin808-working-for-deploys + uses: ./.github/actions/deploy-to-control-plane@justin808-more-work-on-review-apps-1 with: app_name: ${{ env.APP_NAME }} org: ${{ env.CPLN_ORG }} diff --git a/.github/workflows/help-command.yml b/.github/workflows/help-command.yml index d7374900..d4f699fb 100644 --- a/.github/workflows/help-command.yml +++ b/.github/workflows/help-command.yml @@ -22,93 +22,10 @@ jobs: runs-on: ubuntu-latest steps: - - name: Identify Workflow Branch - run: | - echo "Workflow branch ref: ${{ github.ref }}" + - name: Checkout + uses: actions/checkout@justin808-more-work-on-review-apps-1 - - name: Show Available Commands - uses: actions/github-script@v7 + - name: Show Help Information + uses: ./.github/actions/help-command@justin808-more-work-on-review-apps-1 with: - script: | - try { - console.log('Creating detailed help message...'); - const helpMessage = [ - '# 📚 Detailed Review App Commands Guide', - '', - 'This is a detailed guide to using review app commands. For a quick reference, see the message posted when your PR was created.', - '', - '## 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', - '', - '**Optional Configuration:**', - '- `WAIT_TIMEOUT`: Deployment timeout in seconds (default: 900)', - ' - Must be a positive integer', - ' - Can be set in GitHub Actions variables', - ' - Applies to both deployment and workload readiness checks', - '', - '### `/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`', - '', - '**Required Environment Variables:**', - '- `CPLN_TOKEN`: Control Plane authentication token', - '- `CPLN_ORG`: Control Plane organization name', - '', - '### `/help`', - 'Shows this detailed help message.', - '', - '---', - '## Environment Setup', - '', - '**Required Environment Secrets:**', - '- `CPLN_TOKEN_STAGING`: Control Plane authentication token', - '- `CPLN_TOKEN_PRODUCTION`: Control Plane authentication token', - '', - '**Required GitHub Actions Variables:**', - '- `CPLN_ORG_STAGING`: Control Plane authentication token', - '- `CPLN_ORG_PRODUCTION`: Control Plane authentication token', - '', - '**Required GitHub Actions Variables (these need to match your control_plane.yml file:**', - '- `PRODUCTION_APP_NAME`: Control Plane production app name', - '- `STAGING_APP_NAME`: Control Plane staging app name', - '- `REVIEW_APP_PREFIX`: Control Plane review app prefix', - '', - Optional: Configure `WAIT_TIMEOUT` in GitHub Actions variables to customize deployment timeout', - '', - '## Control Plane Integration', - '', - '1. Review app naming convention:', - ' ```', - ' ${{ vars.REVIEW_APP_PREFIX }}-', - ' ```', - '2. Console URL: `https://console.cpln.io/console/org/{CPLN_ORG}/gvc/{APP_NAME}/-info`', - '', - '## Automatic Cleanup', - '', - 'Review apps are automatically deleted when:', - '- The PR is closed (merged or not merged)', - '- The PR is stale (via nightly cleanup job)', - '', - 'For more information, see the [React on Rails Tutorial documentation](https://github.com/shakacode/react-on-rails/tree/master/react-webpack-rails-tutorial)' - ].join('\n'); - - await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number, - body: helpMessage - }); - - console.log('Help message posted successfully'); - } catch (error) { - console.error('Error posting help message:', error); - core.setFailed(`Failed to post help message: ${error.message}`); - } + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/nightly-remove-stale-review-apps.yml b/.github/workflows/nightly-remove-stale-review-apps.yml index 0e8630f3..8f87e4a3 100644 --- a/.github/workflows/nightly-remove-stale-review-apps.yml +++ b/.github/workflows/nightly-remove-stale-review-apps.yml @@ -19,7 +19,7 @@ jobs: uses: actions/checkout@v4 - name: Setup Environment - uses: ./.github/actions/setup-environment@justin808-working-for-deploys + uses: ./.github/actions/setup-environment@justin808-more-work-on-review-apps-1 - name: Get Stale PRs id: stale_prs diff --git a/.github/workflows/promote-staging-to-production.yml b/.github/workflows/promote-staging-to-production.yml index 06cea9cd..373298e2 100644 --- a/.github/workflows/promote-staging-to-production.yml +++ b/.github/workflows/promote-staging-to-production.yml @@ -23,7 +23,7 @@ jobs: uses: actions/checkout@v4 - name: Setup Environment - uses: ./.github/actions/setup-environment@justin808-working-for-deploys + uses: ./.github/actions/setup-environment@justin808-more-work-on-review-apps-1 env: CPLN_TOKEN: ${{ secrets.CPLN_TOKEN }} diff --git a/.github/workflows/review-app-help.yml b/.github/workflows/review-app-help.yml index 313101e4..fbe5d198 100644 --- a/.github/workflows/review-app-help.yml +++ b/.github/workflows/review-app-help.yml @@ -32,10 +32,9 @@ jobs: 'Remove the review app when done', '', '### `/help`', - 'Show detailed documentation', + 'Show detailed instructions, environment setup, and configuration options.' '', '---', - '**Note:** Type `/help` for detailed instructions, environment setup, and configuration options.' ].join('\n'); await github.rest.issues.createComment({ From be2b0d9181459ac51f36f2faac4d351ec02fd3ee Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Mon, 27 Jan 2025 19:17:10 -1000 Subject: [PATCH 3/3] remove branch refs --- .github/actions/help-command/action.yml | 2 +- .github/workflows/delete-review-app.yml | 4 ++-- .github/workflows/deploy-to-control-plane-staging.yml | 2 +- .github/workflows/deploy-to-control-plane.yml | 6 +++--- .github/workflows/help-command.yml | 4 ++-- .github/workflows/nightly-remove-stale-review-apps.yml | 2 +- .github/workflows/promote-staging-to-production.yml | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/actions/help-command/action.yml b/.github/actions/help-command/action.yml index 0e0a1799..a84169a9 100644 --- a/.github/actions/help-command/action.yml +++ b/.github/actions/help-command/action.yml @@ -10,7 +10,7 @@ runs: using: "composite" steps: - name: Show Available Commands - uses: actions/github-script@justin808-more-work-on-review-apps-1 + uses: actions/github-script with: github-token: ${{ inputs.github-token }} script: | diff --git a/.github/workflows/delete-review-app.yml b/.github/workflows/delete-review-app.yml index 6a0178ff..b45282e8 100644 --- a/.github/workflows/delete-review-app.yml +++ b/.github/workflows/delete-review-app.yml @@ -58,7 +58,7 @@ jobs: fi - name: Setup Environment - uses: ./.github/actions/setup-environment@justin808-more-work-on-review-apps-1 + uses: ./.github/actions/setup-environment with: org: ${{ env.CPLN_ORG }} token: ${{ env.CPLN_TOKEN }} @@ -132,7 +132,7 @@ jobs: return { commentId: comment.data.id }; - name: Delete Review App - uses: ./.github/actions/delete-control-plane-app@justin808-more-work-on-review-apps-1 + uses: ./.github/actions/delete-control-plane-app with: app_name: ${{ env.APP_NAME }} org: ${{ env.CPLN_ORG }} diff --git a/.github/workflows/deploy-to-control-plane-staging.yml b/.github/workflows/deploy-to-control-plane-staging.yml index 1fa6b27c..898c447c 100644 --- a/.github/workflows/deploy-to-control-plane-staging.yml +++ b/.github/workflows/deploy-to-control-plane-staging.yml @@ -26,7 +26,7 @@ jobs: fetch-depth: 0 # Fetch all history for proper SHA handling ref: master # Explicitly checkout master branch - - uses: ./.github/actions/deploy-to-control-plane@justin808-more-work-on-review-apps-1 + - uses: ./.github/actions/deploy-to-control-plane with: app_name: ${{ vars.STAGING_APP_NAME }} org: ${{ vars.CPLN_ORG_STAGING }} diff --git a/.github/workflows/deploy-to-control-plane.yml b/.github/workflows/deploy-to-control-plane.yml index b921f39c..dd6110e2 100644 --- a/.github/workflows/deploy-to-control-plane.yml +++ b/.github/workflows/deploy-to-control-plane.yml @@ -40,7 +40,7 @@ jobs: ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || steps.getRef.outputs.PR_REF || github.ref }} - name: Setup Environment - uses: ./.github/actions/setup-environment@justin808-more-work-on-review-apps-1 + uses: ./.github/actions/setup-environment with: token: ${{ env.CPLN_TOKEN }} org: ${{ env.CPLN_ORG }} @@ -228,7 +228,7 @@ jobs: github.event.issue.pull_request && github.event.comment.body == '/deploy-review-app') || (steps.check-app.outputs.app_exists == 'true') - uses: ./.github/actions/build-docker-image@justin808-more-work-on-review-apps-1 + uses: ./.github/actions/build-docker-image with: app_name: ${{ env.APP_NAME }} org: ${{ env.CPLN_ORG }} @@ -269,7 +269,7 @@ jobs: github.event.issue.pull_request && github.event.comment.body == '/deploy-review-app') || (steps.check-app.outputs.app_exists == 'true') - uses: ./.github/actions/deploy-to-control-plane@justin808-more-work-on-review-apps-1 + uses: ./.github/actions/deploy-to-control-plane with: app_name: ${{ env.APP_NAME }} org: ${{ env.CPLN_ORG }} diff --git a/.github/workflows/help-command.yml b/.github/workflows/help-command.yml index d4f699fb..4d92f667 100644 --- a/.github/workflows/help-command.yml +++ b/.github/workflows/help-command.yml @@ -23,9 +23,9 @@ jobs: steps: - name: Checkout - uses: actions/checkout@justin808-more-work-on-review-apps-1 + uses: actions/checkout - name: Show Help Information - uses: ./.github/actions/help-command@justin808-more-work-on-review-apps-1 + uses: ./.github/actions/help-command with: github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/nightly-remove-stale-review-apps.yml b/.github/workflows/nightly-remove-stale-review-apps.yml index 8f87e4a3..c5f0376a 100644 --- a/.github/workflows/nightly-remove-stale-review-apps.yml +++ b/.github/workflows/nightly-remove-stale-review-apps.yml @@ -19,7 +19,7 @@ jobs: uses: actions/checkout@v4 - name: Setup Environment - uses: ./.github/actions/setup-environment@justin808-more-work-on-review-apps-1 + uses: ./.github/actions/setup-environment - name: Get Stale PRs id: stale_prs diff --git a/.github/workflows/promote-staging-to-production.yml b/.github/workflows/promote-staging-to-production.yml index 373298e2..04148067 100644 --- a/.github/workflows/promote-staging-to-production.yml +++ b/.github/workflows/promote-staging-to-production.yml @@ -23,7 +23,7 @@ jobs: uses: actions/checkout@v4 - name: Setup Environment - uses: ./.github/actions/setup-environment@justin808-more-work-on-review-apps-1 + uses: ./.github/actions/setup-environment env: CPLN_TOKEN: ${{ secrets.CPLN_TOKEN }}