Skip to content

Commit 92ad3a7

Browse files
committed
fix-for-delete
1 parent 3426aca commit 92ad3a7

File tree

3 files changed

+92
-6
lines changed

3 files changed

+92
-6
lines changed

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

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,21 @@ jobs:
2323
runs-on: ubuntu-latest
2424

2525
steps:
26+
- name: Debug Trigger Conditions
27+
env:
28+
EVENT_NAME: ${{ github.event_name }}
29+
IS_PR: ${{ github.event.issue.pull_request != '' }}
30+
COMMENT: ${{ github.event.comment.body }}
31+
PR_NUMBER: ${{ github.event.issue.number }}
32+
run: |
33+
echo "Debug information for delete-review-app command:"
34+
echo "Event name: $EVENT_NAME"
35+
echo "Is PR: $IS_PR"
36+
echo "Comment body: $COMMENT"
37+
echo "PR number: $PR_NUMBER"
38+
echo "Raw event payload:"
39+
echo '${{ toJSON(github.event) }}'
40+
2641
- name: Get PR number
2742
id: pr
2843
uses: actions/github-script@v7
@@ -37,6 +52,20 @@ jobs:
3752

3853
- uses: actions/checkout@v4
3954

55+
- name: Validate Required Secrets
56+
run: |
57+
missing_secrets=()
58+
for secret in "CPLN_TOKEN_STAGING" "CPLN_ORG_STAGING"; do
59+
if [ -z "${!secret}" ]; then
60+
missing_secrets+=("$secret")
61+
fi
62+
done
63+
64+
if [ ${#missing_secrets[@]} -ne 0 ]; then
65+
echo "❌ Required secrets are not set: ${missing_secrets[*]}"
66+
exit 1
67+
fi
68+
4069
- name: Setup Environment
4170
uses: ./.github/actions/setup-environment
4271

@@ -55,9 +84,11 @@ jobs:
5584
5685
- name: Delete Review App
5786
uses: ./.github/actions/delete-control-plane-app
87+
with:
88+
app_name: ${{ env.APP_NAME }}
89+
org: ${{ env.CPLN_ORG }}
90+
github_token: ${{ secrets.GITHUB_TOKEN }}
5891
env:
59-
APP_NAME: ${{ env.APP_NAME }}
60-
CPLN_ORG: ${{ secrets.CPLN_ORG }}
6192
CPLN_TOKEN: ${{ secrets.CPLN_TOKEN }}
6293

6394
- name: Update Delete Status

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

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,42 @@ jobs:
5050
fetch-depth: 0
5151
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || steps.getRef.outputs.PR_REF || github.ref }}
5252

53+
- name: Validate Required Secrets
54+
run: |
55+
missing_secrets=()
56+
for secret in "CPLN_TOKEN_STAGING" "CPLN_ORG_STAGING"; do
57+
if [ -z "${!secret}" ]; then
58+
missing_secrets+=("$secret")
59+
fi
60+
done
61+
62+
if [ ${#missing_secrets[@]} -ne 0 ]; then
63+
echo "❌ Required secrets are not set: ${missing_secrets[*]}"
64+
exit 1
65+
fi
66+
5367
- name: Setup Environment
5468
uses: ./.github/actions/setup-environment
5569

70+
- name: Set shared functions
71+
id: shared-functions
72+
uses: actions/github-script@v7
73+
with:
74+
script: |
75+
core.exportVariable('GET_CONSOLE_LINK', `
76+
function getConsoleLink(prNumber) {
77+
return '🎮 [Control Plane Console for Review App with PR #' + prNumber + '](' +
78+
'https://console.cpln.io/org/' + process.env.CPLN_ORG + '/workloads/' + process.env.APP_NAME + ')';
79+
}
80+
`);
81+
5682
- name: Initialize Deployment
5783
id: init-deployment
5884
uses: actions/github-script@v7
5985
with:
6086
script: |
87+
eval(process.env.GET_CONSOLE_LINK);
88+
6189
async function getWorkflowUrl(runId) {
6290
// Get the current job ID
6391
const jobs = await github.rest.actions.listJobsForWorkflowRun({
@@ -117,10 +145,14 @@ jobs:
117145
uses: actions/github-script@v7
118146
with:
119147
script: |
148+
eval(process.env.GET_CONSOLE_LINK);
149+
120150
const buildingMessage = [
121151
'🏗️ Building Docker image for PR #' + process.env.PR_NUMBER + ', commit ' + '${{ env.COMMIT_HASH }}',
122152
'',
123-
'[View Build Logs](' + process.env.WORKFLOW_URL + ')'
153+
'📋 [View Build Logs](' + process.env.WORKFLOW_URL + ')',
154+
'',
155+
getConsoleLink(process.env.PR_NUMBER)
124156
].join('\n');
125157
126158
await github.rest.issues.updateComment({
@@ -142,12 +174,16 @@ jobs:
142174
uses: actions/github-script@v7
143175
with:
144176
script: |
177+
eval(process.env.GET_CONSOLE_LINK);
178+
145179
const deployingMessage = [
146180
'🚀 Deploying to Control Plane...',
147181
'',
148182
'⏳ Waiting for deployment to be ready...',
149183
'',
150-
'[View Deploy Logs](' + process.env.WORKFLOW_URL + ')'
184+
'📋 [View Deploy Logs](' + process.env.WORKFLOW_URL + ')',
185+
'',
186+
getConsoleLink(process.env.PR_NUMBER)
151187
].join('\n');
152188
153189
await github.rest.issues.updateComment({
@@ -168,6 +204,8 @@ jobs:
168204
uses: actions/github-script@v7
169205
with:
170206
script: |
207+
eval(process.env.GET_CONSOLE_LINK);
208+
171209
const prNumber = process.env.PR_NUMBER;
172210
const appUrl = process.env.REVIEW_APP_URL;
173211
const workflowUrl = process.env.WORKFLOW_URL;
@@ -192,13 +230,17 @@ jobs:
192230
'',
193231
'🚀 [Review App for PR #' + prNumber + '](' + appUrl + ')',
194232
'',
195-
'📋 [View Completed Action Build and Deploy Logs](' + workflowUrl + ')'
233+
'📋 [View Completed Action Build and Deploy Logs](' + workflowUrl + ')',
234+
'',
235+
getConsoleLink(prNumber)
196236
].join('\n');
197237
198238
const failureMessage = [
199239
'❌ Deployment failed for PR #' + prNumber + ', commit ' + '${{ env.COMMIT_HASH }}',
200240
'',
201-
'📋 [View Deployment Logs with Errors](' + workflowUrl + ')'
241+
'📋 [View Deployment Logs with Errors](' + workflowUrl + ')',
242+
'',
243+
getConsoleLink(prNumber)
202244
].join('\n');
203245
204246
// Update the existing comment

.github/workflows/help-command.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@ jobs:
1717
runs-on: ubuntu-latest
1818

1919
steps:
20+
- name: Debug Trigger Conditions
21+
env:
22+
EVENT_NAME: ${{ github.event_name }}
23+
IS_PR: ${{ github.event.issue.pull_request != '' }}
24+
COMMENT: ${{ github.event.comment.body }}
25+
run: |
26+
echo "Debug information for help command:"
27+
echo "Event name: $EVENT_NAME"
28+
echo "Is PR: $IS_PR"
29+
echo "Comment body: $COMMENT"
30+
echo "Raw event payload:"
31+
echo '${{ toJSON(github.event) }}'
32+
2033
- name: Show Available Commands
2134
uses: actions/github-script@v7
2235
with:

0 commit comments

Comments
 (0)