From cb5ce31813e9560f58ddf7abd241f4fd4512043c Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Mon, 27 Jan 2025 18:01:45 -1000 Subject: [PATCH] fix issues related to new secrets/variables --- .github/workflows/delete-review-app.yml | 4 +- .../deploy-to-control-plane-staging.yml | 8 +- .github/workflows/deploy-to-control-plane.yml | 4 +- .github/workflows/help-command.yml | 99 +++++++++++++++++++ 4 files changed, 107 insertions(+), 8 deletions(-) diff --git a/.github/workflows/delete-review-app.yml b/.github/workflows/delete-review-app.yml index a7691e3e..3f547579 100644 --- a/.github/workflows/delete-review-app.yml +++ b/.github/workflows/delete-review-app.yml @@ -13,8 +13,8 @@ permissions: issues: write env: - CPLN_ORG: ${{ secrets.CPLN_ORG_STAGING }} - CPLN_TOKEN: ${{ secrets.CPLN_TOKEN }} + CPLN_ORG: ${{ vars.CPLN_ORG_STAGING }} + CPLN_TOKEN: ${{ secrets.CPLN_TOKEN_STAGING }} APP_NAME: qa-react-webpack-rails-tutorial-pr-${{ github.event.pull_request.number || github.event.issue.number }} PR_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }} diff --git a/.github/workflows/deploy-to-control-plane-staging.yml b/.github/workflows/deploy-to-control-plane-staging.yml index 5b178e66..b56511b1 100644 --- a/.github/workflows/deploy-to-control-plane-staging.yml +++ b/.github/workflows/deploy-to-control-plane-staging.yml @@ -13,8 +13,8 @@ on: # Convert the GitHub secret variables to environment variables for use by the Control Plane CLI env: - CPLN_ORG: ${{secrets.CPLN_ORG_STAGING}} - CPLN_TOKEN: ${{secrets.CPLN_TOKEN_STAGING}} + CPLN_ORG: ${{ vars.CPLN_ORG_STAGING }} + CPLN_TOKEN: ${{ secrets.CPLN_TOKEN_STAGING }} jobs: deploy-to-control-plane-staging: @@ -28,5 +28,5 @@ jobs: - uses: ./.github/actions/deploy-to-control-plane@justin808-working-for-deploys with: - app_name: ${{ secrets.APP_NAME_STAGING }} - org: ${{ secrets.CPLN_ORG_STAGING }} + 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 92e97187..35e26082 100644 --- a/.github/workflows/deploy-to-control-plane.yml +++ b/.github/workflows/deploy-to-control-plane.yml @@ -15,8 +15,8 @@ concurrency: env: APP_NAME: qa-react-webpack-rails-tutorial-pr-${{ github.event.pull_request.number || github.event.issue.number }} - CPLN_ORG: ${{ secrets.CPLN_ORG_STAGING }} CPLN_TOKEN: ${{ secrets.CPLN_TOKEN_STAGING }} + CPLN_ORG: ${{ vars.CPLN_ORG_STAGING }} PR_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }} jobs: @@ -25,7 +25,7 @@ jobs: (github.event_name == 'pull_request') || (github.event_name == 'issue_comment' && github.event.issue.pull_request && - github.event.comment.body == '/deploy') + github.event.comment.body == '/deploy-review-app') runs-on: ubuntu-latest permissions: contents: read diff --git a/.github/workflows/help-command.yml b/.github/workflows/help-command.yml index f9376eeb..682ffa1f 100644 --- a/.github/workflows/help-command.yml +++ b/.github/workflows/help-command.yml @@ -18,6 +18,105 @@ jobs: github.event.comment.body == '/help') runs-on: ubuntu-latest + steps: + - name: Show Available Commands + uses: actions/github-script@v7 + 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', + '', + '**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', + ' - 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', + '', + '1. Set required secrets in your repository settings:', + ' - `CPLN_TOKEN`', + ' - `CPLN_ORG`', + '', + '2. 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`', + '', + '## 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, +name: Show Help for Commands + +on: + issue_comment: + types: [created] + +permissions: + issues: write + pull-requests: write + +jobs: + show-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