|
| 1 | +name: 'Show Help Command' |
| 2 | +description: 'Displays help information for available commands in PR comments' |
| 3 | + |
| 4 | +inputs: |
| 5 | + github-token: |
| 6 | + description: 'GitHub token for posting comments' |
| 7 | + required: true |
| 8 | + issue-number: |
| 9 | + description: 'PR/Issue number to post the comment to (optional, defaults to event context)' |
| 10 | + required: false |
| 11 | + |
| 12 | +runs: |
| 13 | + using: "composite" |
| 14 | + steps: |
| 15 | + - name: Show Available Commands |
| 16 | + uses: actions/github-script@v7 |
| 17 | + with: |
| 18 | + github-token: ${{ inputs.github-token }} |
| 19 | + script: | |
| 20 | + const helpText = [ |
| 21 | + '# Available Commands', |
| 22 | + '', |
| 23 | + '## `/deploy`', |
| 24 | + '**Purpose:** Deploy a review app for your pull request', |
| 25 | + '', |
| 26 | + '**What it does:**', |
| 27 | + '- Creates a new review app in Control Plane', |
| 28 | + '- Deploys your changes to the review environment', |
| 29 | + '- Provides a unique URL to preview your changes', |
| 30 | + '- Shows build and deployment progress in real-time', |
| 31 | + '', |
| 32 | + '**Optional Configuration:**', |
| 33 | + '- `WAIT_TIMEOUT`: Deployment timeout in seconds (default: 900)', |
| 34 | + ' - Must be a positive integer', |
| 35 | + ' - Example: `/deploy timeout=1800`', |
| 36 | + '', |
| 37 | + '## `/destroy`', |
| 38 | + '**Purpose:** Remove the review app for your pull request', |
| 39 | + '', |
| 40 | + '**What it does:**', |
| 41 | + '- Deletes the review app from Control Plane', |
| 42 | + '- Cleans up associated resources', |
| 43 | + '- Updates PR with deletion status', |
| 44 | + '', |
| 45 | + '---', |
| 46 | + '## Environment Setup', |
| 47 | + '', |
| 48 | + '**Required Environment Secrets:**', |
| 49 | + '- `CPLN_TOKEN_STAGING`: Control Plane authentication token', |
| 50 | + '- `CPLN_TOKEN_PRODUCTION`: Control Plane authentication token', |
| 51 | + '', |
| 52 | + '**Required GitHub Actions Variables:**', |
| 53 | + '- `CPLN_ORG_STAGING`: Control Plane authentication token', |
| 54 | + '- `CPLN_ORG_PRODUCTION`: Control Plane authentication token', |
| 55 | + '', |
| 56 | + '**Required GitHub Actions Variables (these need to match your control_plane.yml file:**', |
| 57 | + '- `PRODUCTION_APP_NAME`: Control Plane production app name', |
| 58 | + '- `STAGING_APP_NAME`: Control Plane staging app name', |
| 59 | + '- `REVIEW_APP_PREFIX`: Control Plane review app prefix', |
| 60 | + '', |
| 61 | + 'Optional: Configure `WAIT_TIMEOUT` in GitHub Actions variables to customize deployment timeout', |
| 62 | + '', |
| 63 | + '## Control Plane Integration', |
| 64 | + '', |
| 65 | + '1. Review app naming convention:', |
| 66 | + ' ```', |
| 67 | + ' ${{ vars.REVIEW_APP_PREFIX }}-<pr-number>', |
| 68 | + ' ```', |
| 69 | + '2. Console URL: `https://console.cpln.io/console/org/{CPLN_ORG}/gvc/{APP_NAME}/-info`', |
| 70 | + '', |
| 71 | + '## Automatic Cleanup', |
| 72 | + '', |
| 73 | + 'Review apps are automatically destroyed when:', |
| 74 | + '1. The pull request is closed', |
| 75 | + '2. The `/destroy` command is used', |
| 76 | + '3. A new deployment is requested (old one is cleaned up first)', |
| 77 | + '', |
| 78 | + '## Need Help?', |
| 79 | + '', |
| 80 | + 'For additional assistance:', |
| 81 | + '1. Check the [Control Plane documentation](https://docs.controlplane.com/)', |
| 82 | + '2. Contact the infrastructure team', |
| 83 | + '3. Open an issue in this repository', |
| 84 | + ].join('\n'); |
| 85 | +
|
| 86 | + const issueNumber = inputs['issue-number'] || |
| 87 | + (context.eventName === 'issue_comment' ? context.payload.issue.number : null); |
| 88 | +
|
| 89 | + if (issueNumber) { |
| 90 | + await github.rest.issues.createComment({ |
| 91 | + owner: context.repo.owner, |
| 92 | + repo: context.repo.repo, |
| 93 | + issue_number: issueNumber, |
| 94 | + body: helpText |
| 95 | + }); |
| 96 | + } else { |
| 97 | + console.log(helpText); |
| 98 | + } |
0 commit comments