diff --git a/.github/actions/help-command/action.yml b/.github/actions/help-command/action.yml new file mode 100644 index 00000000..a84169a9 --- /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 + 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..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-working-for-deploys + 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-working-for-deploys + 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 b56511b1..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-working-for-deploys + - 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 35e26082..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-working-for-deploys + 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-working-for-deploys + 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-working-for-deploys + 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 90f19a2c..4d92f667 100644 --- a/.github/workflows/help-command.yml +++ b/.github/workflows/help-command.yml @@ -22,95 +22,10 @@ jobs: runs-on: ubuntu-latest steps: - - name: Identify Workflow Branch - run: | - echo "Workflow branch ref: ${{ github.ref }}" + - name: Checkout + uses: actions/checkout - - name: Show Available Commands - uses: actions/github-script@v7 + - name: Show Help Information + uses: ./.github/actions/help-command 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, - 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..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-working-for-deploys + 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 06cea9cd..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-working-for-deploys + uses: ./.github/actions/setup-environment 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({