Skip to content

Commit 0c5fb50

Browse files
committed
Refactor, inline help-command
1 parent 33ce218 commit 0c5fb50

File tree

2 files changed

+127
-127
lines changed

2 files changed

+127
-127
lines changed

.github/actions/help-command/action.yml

Lines changed: 0 additions & 98 deletions
This file was deleted.

.github/workflows/help-command.yml

Lines changed: 127 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,140 @@
1-
name: Show Help for Commands
1+
name: Help Command
22

33
on:
4-
push:
5-
branches:
6-
- "**" # Trigger on all branches, including feature branches
74
issue_comment:
85
types: [created]
9-
workflow_dispatch:
10-
inputs:
11-
issue-number:
12-
description: 'PR/Issue number to post the help comment to'
13-
required: true
14-
type: number
156

167
permissions:
178
issues: write
189
pull-requests: write
1910

2011
jobs:
21-
debug:
22-
uses: ./.github/workflows/debug-workflow.yml
23-
with:
24-
debug_enabled: false # Will still run if vars.DEBUG_WORKFLOW is true
25-
26-
show-help:
27-
if: |
28-
github.event_name == 'workflow_dispatch' ||
29-
(github.event_name == 'issue_comment' &&
30-
github.event.issue.pull_request &&
31-
github.event.comment.body == '/help')
12+
help:
13+
if: ${{ github.event.issue.pull_request && github.event.comment.body == '/help' }}
3214
runs-on: ubuntu-latest
33-
15+
3416
steps:
35-
- name: Checkout
36-
uses: actions/checkout
37-
38-
- name: Process Help Command
39-
uses: ./.github/actions/help-command
17+
- name: Show Available Commands
18+
uses: actions/github-script@v7
4019
with:
41-
github-token: ${{ secrets.GITHUB_TOKEN }}
42-
issue-number: ${{ github.event.inputs.issue-number }}
20+
script: |
21+
const sections = {
22+
commands: {
23+
deploy: {
24+
title: '## `/deploy`',
25+
purpose: '**Purpose:** Deploy a review app for your pull request',
26+
details: [
27+
'**What it does:**',
28+
'- Creates a new review app in Control Plane',
29+
'- Deploys your changes to the review environment',
30+
'- Provides a unique URL to preview your changes',
31+
'- Shows build and deployment progress in real-time',
32+
'',
33+
'**Optional Configuration:**',
34+
'- `WAIT_TIMEOUT`: Deployment timeout in seconds (default: 900)',
35+
' - Must be a positive integer',
36+
' - Example: `/deploy timeout=1800`'
37+
]
38+
},
39+
destroy: {
40+
title: '## `/destroy`',
41+
purpose: '**Purpose:** Remove the review app for your pull request',
42+
details: [
43+
'**What it does:**',
44+
'- Deletes the review app from Control Plane',
45+
'- Cleans up associated resources',
46+
'- Updates PR with deletion status'
47+
]
48+
}
49+
},
50+
setup: {
51+
title: '## Environment Setup',
52+
sections: [
53+
{
54+
title: '**Required Environment Secrets:**',
55+
items: [
56+
'- `CPLN_TOKEN_STAGING`: Control Plane authentication token',
57+
'- `CPLN_TOKEN_PRODUCTION`: Control Plane authentication token'
58+
]
59+
},
60+
{
61+
title: '**Required GitHub Actions Variables:**',
62+
items: [
63+
'- `CPLN_ORG_STAGING`: Control Plane authentication token',
64+
'- `CPLN_ORG_PRODUCTION`: Control Plane authentication token'
65+
]
66+
},
67+
{
68+
title: '**Required GitHub Actions Variables (these need to match your control_plane.yml file:**',
69+
items: [
70+
'- `PRODUCTION_APP_NAME`: Control Plane production app name',
71+
'- `STAGING_APP_NAME`: Control Plane staging app name',
72+
'- `REVIEW_APP_PREFIX`: Control Plane review app prefix'
73+
]
74+
}
75+
],
76+
note: 'Optional: Configure `WAIT_TIMEOUT` in GitHub Actions variables to customize deployment timeout'
77+
},
78+
integration: {
79+
title: '## Control Plane Integration',
80+
details: [
81+
'1. Review app naming convention:',
82+
' ```',
83+
' ${{ vars.REVIEW_APP_PREFIX }}-<pr-number>',
84+
' ```',
85+
'2. Console URL: `https://console.cpln.io/console/org/{CPLN_ORG}/gvc/{APP_NAME}/-info`'
86+
]
87+
},
88+
cleanup: {
89+
title: '## Automatic Cleanup',
90+
details: [
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+
},
97+
help: {
98+
title: '## Need Help?',
99+
details: [
100+
'For additional assistance:',
101+
'1. Check the [Control Plane documentation](https://docs.controlplane.com/)',
102+
'2. Contact the infrastructure team',
103+
'3. Open an issue in this repository'
104+
]
105+
}
106+
};
107+
108+
const generateHelpText = () => {
109+
const parts = ['# Available Commands', ''];
110+
111+
// Add commands
112+
Object.values(sections.commands).forEach(cmd => {
113+
parts.push(cmd.title, cmd.purpose, '', ...cmd.details, '');
114+
});
115+
116+
parts.push('---');
117+
118+
// Add setup section
119+
parts.push(sections.setup.title, '');
120+
sections.setup.sections.forEach(section => {
121+
parts.push(section.title, ...section.items, '');
122+
});
123+
parts.push(sections.setup.note, '');
124+
125+
// Add remaining sections
126+
['integration', 'cleanup', 'help'].forEach(section => {
127+
parts.push(sections[section].title, '', ...sections[section].details, '');
128+
});
129+
130+
return parts.join('\n');
131+
};
132+
133+
const helpText = generateHelpText();
134+
135+
await github.rest.issues.createComment({
136+
owner: context.repo.owner,
137+
repo: context.repo.repo,
138+
issue_number: context.issue.number,
139+
body: helpText
140+
});

0 commit comments

Comments
 (0)