|
31 | 31 | uses: actions/checkout
|
32 | 32 |
|
33 | 33 | - name: Show Help Information
|
34 |
| - uses: ./.github/actions/help-command |
| 34 | + uses: actions/github-script |
35 | 35 | with:
|
36 | 36 | github-token: ${{ secrets.GITHUB_TOKEN }}
|
37 |
| - issue-number: ${{ github.event.inputs.issue-number }} |
| 37 | + script: | |
| 38 | + const helpText = [ |
| 39 | + '# Available Commands', |
| 40 | + '', |
| 41 | + '## `/deploy`', |
| 42 | + '**Purpose:** Deploy a review app for your pull request', |
| 43 | + '', |
| 44 | + '**What it does:**', |
| 45 | + '- Creates a new review app in Control Plane', |
| 46 | + '- Deploys your changes to the review environment', |
| 47 | + '- Provides a unique URL to preview your changes', |
| 48 | + '- Shows build and deployment progress in real-time', |
| 49 | + '', |
| 50 | + '**Optional Configuration:**', |
| 51 | + '- `WAIT_TIMEOUT`: Deployment timeout in seconds (default: 900)', |
| 52 | + ' - Must be a positive integer', |
| 53 | + ' - Example: `/deploy timeout=1800`', |
| 54 | + '', |
| 55 | + '## `/destroy`', |
| 56 | + '**Purpose:** Remove the review app for your pull request', |
| 57 | + '', |
| 58 | + '**What it does:**', |
| 59 | + '- Deletes the review app from Control Plane', |
| 60 | + '- Cleans up associated resources', |
| 61 | + '- Updates PR with deletion status', |
| 62 | + '', |
| 63 | + '---', |
| 64 | + '## Environment Setup', |
| 65 | + '', |
| 66 | + '**Required Environment Secrets:**', |
| 67 | + '- `CPLN_TOKEN_STAGING`: Control Plane authentication token', |
| 68 | + '- `CPLN_TOKEN_PRODUCTION`: Control Plane authentication token', |
| 69 | + '', |
| 70 | + '**Required GitHub Actions Variables:**', |
| 71 | + '- `CPLN_ORG_STAGING`: Control Plane authentication token', |
| 72 | + '- `CPLN_ORG_PRODUCTION`: Control Plane authentication token', |
| 73 | + '', |
| 74 | + '**Required GitHub Actions Variables (these need to match your control_plane.yml file:**', |
| 75 | + '- `PRODUCTION_APP_NAME`: Control Plane production app name', |
| 76 | + '- `STAGING_APP_NAME`: Control Plane staging app name', |
| 77 | + '- `REVIEW_APP_PREFIX`: Control Plane review app prefix', |
| 78 | + '', |
| 79 | + 'Optional: Configure `WAIT_TIMEOUT` in GitHub Actions variables to customize deployment timeout', |
| 80 | + '', |
| 81 | + '## Control Plane Integration', |
| 82 | + '', |
| 83 | + '1. Review app naming convention:', |
| 84 | + ' ```', |
| 85 | + ' ${{ vars.REVIEW_APP_PREFIX }}-<pr-number>', |
| 86 | + ' ```', |
| 87 | + '2. Console URL: `https://console.cpln.io/console/org/{CPLN_ORG}/gvc/{APP_NAME}/-info`', |
| 88 | + '', |
| 89 | + '## Automatic Cleanup', |
| 90 | + '', |
| 91 | + 'Review apps are automatically destroyed when:', |
| 92 | + '1. The pull request is closed', |
| 93 | + '2. The `/destroy` command is used', |
| 94 | + '3. A new deployment is requested (old one is cleaned up first)', |
| 95 | + '', |
| 96 | + '## Need Help?', |
| 97 | + '', |
| 98 | + 'For additional assistance:', |
| 99 | + '1. Check the [Control Plane documentation](https://docs.controlplane.com/)', |
| 100 | + '2. Contact the infrastructure team', |
| 101 | + '3. Open an issue in this repository', |
| 102 | + ].join('\n'); |
| 103 | +
|
| 104 | + const issueNumber = context.payload.inputs?.['issue-number'] || |
| 105 | + (context.eventName === 'issue_comment' ? context.payload.issue.number : null); |
| 106 | +
|
| 107 | + if (issueNumber) { |
| 108 | + await github.rest.issues.createComment({ |
| 109 | + owner: context.repo.owner, |
| 110 | + repo: context.repo.repo, |
| 111 | + issue_number: issueNumber, |
| 112 | + body: helpText |
| 113 | + }); |
| 114 | + } else { |
| 115 | + console.log(helpText); |
| 116 | + } |
0 commit comments