Skip to content

Commit 6add086

Browse files
authored
More work on github actions (#621)
1 parent 098b886 commit 6add086

8 files changed

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

.github/workflows/delete-review-app.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
fi
5959
6060
- name: Setup Environment
61-
uses: ./.github/actions/setup-environment@justin808-working-for-deploys
61+
uses: ./.github/actions/setup-environment
6262
with:
6363
org: ${{ env.CPLN_ORG }}
6464
token: ${{ env.CPLN_TOKEN }}
@@ -132,7 +132,7 @@ jobs:
132132
return { commentId: comment.data.id };
133133
134134
- name: Delete Review App
135-
uses: ./.github/actions/delete-control-plane-app@justin808-working-for-deploys
135+
uses: ./.github/actions/delete-control-plane-app
136136
with:
137137
app_name: ${{ env.APP_NAME }}
138138
org: ${{ env.CPLN_ORG }}

.github/workflows/deploy-to-control-plane-staging.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
fetch-depth: 0 # Fetch all history for proper SHA handling
2727
ref: master # Explicitly checkout master branch
2828

29-
- uses: ./.github/actions/deploy-to-control-plane@justin808-working-for-deploys
29+
- uses: ./.github/actions/deploy-to-control-plane
3030
with:
3131
app_name: ${{ vars.STAGING_APP_NAME }}
3232
org: ${{ vars.CPLN_ORG_STAGING }}

.github/workflows/deploy-to-control-plane.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || steps.getRef.outputs.PR_REF || github.ref }}
4141

4242
- name: Setup Environment
43-
uses: ./.github/actions/setup-environment@justin808-working-for-deploys
43+
uses: ./.github/actions/setup-environment
4444
with:
4545
token: ${{ env.CPLN_TOKEN }}
4646
org: ${{ env.CPLN_ORG }}
@@ -228,7 +228,7 @@ jobs:
228228
github.event.issue.pull_request &&
229229
github.event.comment.body == '/deploy-review-app') ||
230230
(steps.check-app.outputs.app_exists == 'true')
231-
uses: ./.github/actions/build-docker-image@justin808-working-for-deploys
231+
uses: ./.github/actions/build-docker-image
232232
with:
233233
app_name: ${{ env.APP_NAME }}
234234
org: ${{ env.CPLN_ORG }}
@@ -269,7 +269,7 @@ jobs:
269269
github.event.issue.pull_request &&
270270
github.event.comment.body == '/deploy-review-app') ||
271271
(steps.check-app.outputs.app_exists == 'true')
272-
uses: ./.github/actions/deploy-to-control-plane@justin808-working-for-deploys
272+
uses: ./.github/actions/deploy-to-control-plane
273273
with:
274274
app_name: ${{ env.APP_NAME }}
275275
org: ${{ env.CPLN_ORG }}

.github/workflows/help-command.yml

+5-90
Original file line numberDiff line numberDiff line change
@@ -22,95 +22,10 @@ jobs:
2222
runs-on: ubuntu-latest
2323

2424
steps:
25-
- name: Identify Workflow Branch
26-
run: |
27-
echo "Workflow branch ref: ${{ github.ref }}"
25+
- name: Checkout
26+
uses: actions/checkout
2827

29-
- name: Show Available Commands
30-
uses: actions/github-script@v7
28+
- name: Show Help Information
29+
uses: ./.github/actions/help-command
3130
with:
32-
script: |
33-
try {
34-
console.log('Creating detailed help message...');
35-
const helpMessage = [
36-
'# 📚 Detailed Review App Commands Guide',
37-
'',
38-
'This is a detailed guide to using review app commands. For a quick reference, see the message posted when your PR was created.',
39-
'',
40-
'## Available Commands',
41-
'',
42-
'### `/deploy-review-app`',
43-
'Deploys your PR branch to a review environment on Control Plane.',
44-
'- Creates a new review app if one doesn\'t exist',
45-
'- Updates the existing review app if it already exists',
46-
'- Provides a unique URL to preview your changes',
47-
'- Shows build and deployment progress in real-time',
48-
'',
49-
'**Required Environment Secrets:**',
50-
'- `CPLN_TOKEN_STAGING`: Control Plane authentication token',
51-
'- `CPLN_TOKEN_PRODUCTION`: Control Plane authentication token',
52-
'',
53-
'**Required GitHub Actions Variables:**',
54-
'- `CPLN_ORG_STAGING`: Control Plane authentication token',
55-
'- `CPLN_ORG_PRODUCTION`: Control Plane authentication token',
56-
'',
57-
'**Required GitHub Actions Variables (these need to match your control_plane.yml file:**',
58-
'- `PRODUCTION_APP_NAME`: Control Plane production app name',
59-
'- `STAGING_APP_NAME`: Control Plane staging app name',
60-
'- `REVIEW_APP_PREFIX`: Control Plane review app prefix',
61-
'',
62-
'**Optional Configuration:**',
63-
'- `WAIT_TIMEOUT`: Deployment timeout in seconds (default: 900)',
64-
' - Must be a positive integer',
65-
' - Can be set in GitHub Actions variables',
66-
' - Applies to both deployment and workload readiness checks',
67-
'',
68-
'### `/delete-review-app`',
69-
'Deletes the review app associated with this PR.',
70-
'- Removes all resources from Control Plane',
71-
'- Helpful for cleaning up when you\'re done testing',
72-
'- Can be re-deployed later using `/deploy-review-app`',
73-
'',
74-
'**Required Environment Variables:**',
75-
'- `CPLN_TOKEN`: Control Plane authentication token',
76-
'- `CPLN_ORG`: Control Plane organization name',
77-
'',
78-
'### `/help`',
79-
'Shows this detailed help message.',
80-
'',
81-
'---',
82-
'## Environment Setup',
83-
'',
84-
'1. Set required secrets in your repository settings:',
85-
' - `CPLN_TOKEN`',
86-
' - `CPLN_ORG`',
87-
'',
88-
'2. Optional: Configure `WAIT_TIMEOUT` in GitHub Actions variables to customize deployment timeout',
89-
'',
90-
'## Control Plane Integration',
91-
'',
92-
'Review apps are deployed to Control Plane with the following configuration:',
93-
'- App Name Format: `qa-react-webpack-rails-tutorial-pr-{PR_NUMBER}`',
94-
'- Console URL: `https://console.cpln.io/console/org/{CPLN_ORG}/gvc/{APP_NAME}/-info`',
95-
'',
96-
'## Automatic Cleanup',
97-
'',
98-
'Review apps are automatically deleted when:',
99-
'- The PR is closed (merged or not merged)',
100-
'- The PR is stale (via nightly cleanup job)',
101-
'',
102-
'For more information, see the [React on Rails Tutorial documentation](https://github.com/shakacode/react-on-rails/tree/master/react-webpack-rails-tutorial)'
103-
].join('\n');
104-
105-
await github.rest.issues.createComment({
106-
owner: context.repo.owner,
107-
repo: context.repo.repo,
108-
issue_number: context.issue.number,
109-
body: helpMessage
110-
});
111-
112-
console.log('Help message posted successfully');
113-
} catch (error) {
114-
console.error('Error posting help message:', error);
115-
core.setFailed(`Failed to post help message: ${error.message}`);
116-
}
31+
github-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/nightly-remove-stale-review-apps.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
uses: actions/checkout@v4
2020

2121
- name: Setup Environment
22-
uses: ./.github/actions/setup-environment@justin808-working-for-deploys
22+
uses: ./.github/actions/setup-environment
2323

2424
- name: Get Stale PRs
2525
id: stale_prs

.github/workflows/promote-staging-to-production.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
uses: actions/checkout@v4
2424

2525
- name: Setup Environment
26-
uses: ./.github/actions/setup-environment@justin808-working-for-deploys
26+
uses: ./.github/actions/setup-environment
2727
env:
2828
CPLN_TOKEN: ${{ secrets.CPLN_TOKEN }}
2929

.github/workflows/review-app-help.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@ jobs:
3232
'Remove the review app when done',
3333
'',
3434
'### `/help`',
35-
'Show detailed documentation',
35+
'Show detailed instructions, environment setup, and configuration options.'
3636
'',
3737
'---',
38-
'**Note:** Type `/help` for detailed instructions, environment setup, and configuration options.'
3938
].join('\n');
4039
4140
await github.rest.issues.createComment({

0 commit comments

Comments
 (0)