Skip to content

Commit ebbc8d8

Browse files
authoredJan 28, 2025··
More work on actions (#622)
1 parent 6add086 commit ebbc8d8

File tree

6 files changed

+245
-170
lines changed

6 files changed

+245
-170
lines changed
 

‎.github/actions/deploy-to-control-plane/action.yml‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ inputs:
1717
description: 'Timeout in seconds for waiting for workloads to be ready'
1818
required: false
1919
default: '900'
20+
cpln_token:
21+
description: 'Control Plane token'
22+
required: true
23+
pr_number:
24+
description: 'Pull Request number'
25+
required: true
2026

2127
outputs:
2228
review_app_url:
@@ -50,11 +56,14 @@ runs:
5056
run: ${{ github.action_path }}/scripts/get-commit-sha.sh
5157
env:
5258
GITHUB_TOKEN: ${{ inputs.github_token }}
53-
PR_NUMBER: ${{ env.PR_NUMBER }}
59+
PR_NUMBER: ${{ inputs.pr_number }}
5460

5561
- name: Deploy to Control Plane
5662
id: deploy
5763
shell: bash
64+
env:
65+
CPLN_TOKEN: ${{ inputs.cpln_token }}
66+
PR_NUMBER: ${{ inputs.pr_number }}
5867
run: |
5968
echo "🚀 Deploying app for PR #${PR_NUMBER}..."
6069

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ inputs:
55
github-token:
66
description: 'GitHub token for posting comments'
77
required: true
8+
issue-number:
9+
description: 'PR/Issue number to post the comment to (optional, defaults to event context)'
10+
required: false
811

912
runs:
1013
using: "composite"
1114
steps:
1215
- name: Show Available Commands
13-
uses: actions/github-script
16+
uses: actions/github-script@v7
1417
with:
1518
github-token: ${{ inputs.github-token }}
1619
script: |
@@ -80,12 +83,14 @@ runs:
8083
'3. Open an issue in this repository',
8184
].join('\n');
8285
83-
const context = github.context;
84-
if (context.eventName === 'issue_comment') {
86+
const issueNumber = inputs['issue-number'] ||
87+
(context.eventName === 'issue_comment' ? context.payload.issue.number : null);
88+
89+
if (issueNumber) {
8590
await github.rest.issues.createComment({
8691
owner: context.repo.owner,
8792
repo: context.repo.repo,
88-
issue_number: context.payload.issue.number,
93+
issue_number: issueNumber,
8994
body: helpText
9095
});
9196
} else {

‎.github/actions/setup-environment/action.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ runs:
2222
- name: Install Control Plane CLI and cpflow gem
2323
shell: bash
2424
run: |
25-
sudo npm install -g @controlplane/cli@3.3.0
25+
sudo npm install -g @controlplane/cli@3.3.1
2626
cpln --version
2727
gem install cpflow -v 4.1.0
2828
cpflow --version

‎.github/readme.md‎

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Developing and Testing Github Actions
2+
3+
Testing Github Actions on an existing repository is tricky.
4+
5+
The main issue boils down to the fact that Github Actions uses the workflow files in the branch where the event originates. This is fine for push events, but it becomes a problem when you want to test workflows that are triggered by comments on a pull request.
6+
7+
Here's a summary of the behavior:
8+
9+
Behavior of push and pull_request Events
10+
1. Push on a Branch:
11+
• When you push changes to a branch (e.g., feature-branch), GitHub Actions uses the workflow files in that same branch.
12+
• This is why changes to workflows work seamlessly when testing with push events.
13+
2. Pull Request Events:
14+
• For pull_request events (e.g., a PR from feature-branch into master), GitHub Actions will always use the workflow files from the target branch (e.g., master), not the source branch (e.g., feature-branch).
15+
• This is a security feature to prevent someone from introducing malicious code in a PR that modifies the workflow files themselves.
16+
17+
Impact on Comment-Triggered Workflows
18+
19+
When you want to trigger workflows via comments (issue_comment) in a pull request:
20+
• The workflow code used will always come from the master branch (or the default branch), regardless of the branch where the PR originates.
21+
• This means the PR’s changes to the workflow won’t be used, and the action invoked by the comment will also use code from master.
22+
23+
Workarounds to Test Comment-Triggered Workflows
24+
25+
If you want to test workflows in a way that uses the changes in the pull request, here are your options:
26+
27+
1. Use Push Events for Testing
28+
• Test your changes on a branch with push triggers.
29+
• Use workflow_dispatch to simulate the events you need (like invoking actions via comments).
30+
31+
This allows you to confirm that your changes to the workflow file or actions behave as expected before merging into master.
32+
33+
2. Merge the Workflow to master Temporarily
34+
35+
If you absolutely need the workflow to run as part of a pull_request event:
36+
1. Merge your workflow changes into master temporarily.
37+
2. Open a PR to test your comment-triggered workflows.
38+
3. Revert the changes in master if necessary.
39+
40+
This ensures the workflow changes are active in master while still testing with the pull_request context.
41+
42+
3. Add Logic to Detect the Source Branch
43+
44+
Use github.event.pull_request.head.ref to add custom logic in your workflow that behaves differently based on the source branch.
45+
• Example:
46+
47+
jobs:
48+
test-pr:
49+
runs-on: ubuntu-latest
50+
if: ${{ github.event.pull_request.head.ref == 'feature-branch' }}
51+
steps:
52+
- name: Checkout Code
53+
uses: actions/checkout@v3
54+
55+
- name: Debug
56+
run: echo "Testing workflow changes in feature-branch"
57+
58+
However, this still requires the workflow itself to exist in master.
59+
60+
4. Use a Fork or a Temporary Repo
61+
62+
Create a temporary repository or a fork to test workflows in isolation:
63+
• Push your workflow changes to master in the test repository.
64+
• Open a PR in the fork to test how workflows behave with issue_comment events and PR contexts.
65+
66+
Once confirmed, you can replicate the changes in your main repository.
67+
68+
6. Alternative Approach: Split Workflows
69+
70+
If your workflow includes comment-based triggers (issue_comment), consider splitting your workflows:
71+
• A base workflow in master that handles triggering.
72+
• A test-specific workflow for validating changes on a branch.
73+
74+
For example:
75+
1. The base workflow triggers when a comment like /run-tests is added.
76+
2. The test-specific workflow runs in response to the base workflow but uses the branch’s code.
77+
78+
Summary
79+
• For push events: The branch-specific workflow is used, so testing changes is easy.
80+
• For pull_request and issue_comment events: GitHub always uses workflows from the master branch, and there’s no direct way to bypass this.
81+
82+
To test comment-triggered workflows:
83+
1. Use push or workflow_dispatch to validate changes.
84+
2. Merge workflow changes temporarily into master to test with pull_request events.
85+
3. Use tools like act for local simulation.
Lines changed: 133 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,40 @@
11
name: Deploy Review App to Control Plane
22

3-
run-name: ${{ github.event_name == 'issue_comment' && 'Deploying Review App' || format('Updating Review App for {0}', github.ref_name) }}
3+
run-name: Deploy Review App - ${{ github.ref_name }}
44

55
on:
66
pull_request:
77
types: [opened, synchronize, reopened]
8+
push:
9+
branches:
10+
- '**' # Any branch
11+
- '!main' # Except main
12+
- '!master' # Except master
813
issue_comment:
914
types: [created]
15+
workflow_dispatch:
16+
inputs:
17+
pr_number:
18+
description: 'Pull Request number to deploy'
19+
required: true
20+
type: number
1021

11-
# Use concurrency to cancel in-progress runs
1222
concurrency:
13-
group: deploy-pr-${{ github.event.pull_request.number || github.event.issue.number }}
23+
group: deploy-pr-${{ github.event.pull_request.number || github.event.issue.number || github.event.inputs.pr_number }}
1424
cancel-in-progress: true
1525

1626
env:
17-
APP_NAME: qa-react-webpack-rails-tutorial-pr-${{ github.event.pull_request.number || github.event.issue.number }}
27+
APP_NAME: qa-react-webpack-rails-tutorial-pr-${{ github.event.pull_request.number || github.event.issue.number || github.event.inputs.pr_number }}
1828
CPLN_TOKEN: ${{ secrets.CPLN_TOKEN_STAGING }}
1929
CPLN_ORG: ${{ vars.CPLN_ORG_STAGING }}
20-
PR_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }}
30+
PR_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number || github.event.inputs.pr_number }}
2131

2232
jobs:
2333
Process-Deployment-Command:
2434
if: |
2535
(github.event_name == 'pull_request') ||
36+
(github.event_name == 'push') ||
37+
(github.event_name == 'workflow_dispatch') ||
2638
(github.event_name == 'issue_comment' &&
2739
github.event.issue.pull_request &&
2840
github.event.comment.body == '/deploy-review-app')
@@ -34,252 +46,211 @@ jobs:
3446
issues: write
3547

3648
steps:
37-
- uses: actions/checkout@v4
49+
# Initial checkout only for pull_request and push events
50+
- name: Checkout code
51+
if: github.event_name == 'pull_request' || github.event_name == 'push'
52+
uses: actions/checkout@v4
3853
with:
3954
fetch-depth: 0
40-
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || steps.getRef.outputs.PR_REF || github.ref }}
55+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.ref }}
4156

42-
- name: Setup Environment
43-
uses: ./.github/actions/setup-environment
57+
# Basic checkout for other events (workflow_dispatch, issue_comment)
58+
# We'll do proper checkout after getting PR info
59+
- name: Initial checkout
60+
if: github.event_name == 'workflow_dispatch' || github.event_name == 'issue_comment'
61+
uses: actions/checkout@v4
4462
with:
45-
token: ${{ env.CPLN_TOKEN }}
46-
org: ${{ env.CPLN_ORG }}
63+
fetch-depth: 0
4764

4865
- name: Get PR HEAD Ref
49-
if: github.event_name == 'issue_comment'
50-
run: |
51-
echo "PR_NUMBER=${{ github.event.issue.number }}" >> $GITHUB_ENV
52-
echo "APP_NAME=qa-react-webpack-rails-tutorial-pr-${{ github.event.issue.number }}" >> $GITHUB_ENV
53-
# For PR comments, get the actual PR head commit
54-
PR_DATA=$(gh pr view $PR_NUMBER --repo ${{ github.repository }} --json headRefName,headRefOid)
55-
echo "PR_REF=$(echo "$PR_DATA" | jq -r '.headRefName')" >> $GITHUB_OUTPUT
56-
echo "PR_SHA=$(echo "$PR_DATA" | jq -r '.headRefOid')" >> $GITHUB_OUTPUT
66+
id: getRef
5767
env:
58-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69+
run: |
70+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
71+
PR_NUMBER="${{ github.event.inputs.pr }}"
72+
elif [[ "${{ github.event_name }}" == "issue_comment" ]]; then
73+
PR_NUMBER="${{ github.event.issue.number }}"
74+
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
75+
PR_NUMBER="${{ github.event.pull_request.number }}"
76+
elif [[ "${{ github.event_name }}" == "push" ]]; then
77+
# For push events, find associated PR
78+
PR_DATA=$(gh pr list --head "${{ github.ref_name }}" --json number --jq '.[0].number')
79+
if [[ -n "$PR_DATA" ]]; then
80+
PR_NUMBER="$PR_DATA"
81+
else
82+
echo "Error: No PR found for branch ${{ github.ref_name }}"
83+
exit 1
84+
fi
85+
fi
86+
87+
if [[ -z "$PR_NUMBER" ]]; then
88+
echo "Error: Could not determine PR number"
89+
exit 1
90+
fi
91+
92+
# Set environment variables
93+
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
94+
echo "APP_NAME=qa-react-webpack-rails-tutorial-pr-$PR_NUMBER" >> $GITHUB_ENV
95+
96+
# Get PR data using GitHub CLI
97+
PR_DATA=$(gh pr view $PR_NUMBER --repo shakacode/react-webpack-rails-tutorial --json headRefName,headRefOid)
98+
if [[ $? -eq 0 ]]; then
99+
echo "PR_REF=$(echo $PR_DATA | jq -r .headRefName)" >> $GITHUB_OUTPUT
100+
echo "PR_SHA=$(echo $PR_DATA | jq -r .headRefOid)" >> $GITHUB_ENV
101+
else
102+
echo "Error: Could not fetch PR data for PR #$PR_NUMBER"
103+
exit 1
104+
fi
105+
106+
- name: Checkout PR code
107+
if: github.event_name == 'workflow_dispatch' || github.event_name == 'issue_comment'
108+
uses: actions/checkout@v4
109+
with:
110+
fetch-depth: 0
111+
ref: ${{ steps.getRef.outputs.PR_SHA }}
112+
113+
- name: Setup Environment
114+
uses: ./.github/actions/setup-environment
115+
with:
116+
token: ${{ secrets.CPLN_TOKEN_STAGING }}
117+
org: ${{ vars.CPLN_ORG_STAGING }}
59118

60119
- name: Check if Review App Exists
61120
id: check-app
62-
if: github.event_name == 'push'
121+
if: github.event_name == 'pull_request'
63122
env:
64-
CPLN_TOKEN: ${{ secrets.CPLN_TOKEN }}
123+
CPLN_TOKEN: ${{ secrets.CPLN_TOKEN_STAGING }}
65124
run: |
125+
# First check if cpflow exists
126+
if ! command -v cpflow &> /dev/null; then
127+
echo "Error: cpflow command not found"
128+
exit 1
129+
fi
130+
131+
# Then check if app exists
66132
if ! cpflow exists -a ${{ env.APP_NAME }}; then
67133
echo "No review app exists for this PR"
68-
exit 0
134+
echo "DO_DEPLOY=false" >> $GITHUB_ENV
135+
else
136+
echo "DO_DEPLOY=true" >> $GITHUB_ENV
69137
fi
70-
echo "app_exists=true" >> $GITHUB_OUTPUT
71138
72-
73-
- name: Set Workflow URL
74-
id: workflow-url
75-
uses: actions/github-script@v7
76-
with:
77-
script: |
78-
async function getWorkflowUrl(runId) {
79-
const jobs = await github.rest.actions.listJobsForWorkflowRun({
80-
owner: context.repo.owner,
81-
repo: context.repo.repo,
82-
run_id: runId
83-
});
84-
85-
const currentJob = jobs.data.jobs.find(job => job.status === 'in_progress');
86-
const jobId = currentJob?.id;
87-
88-
if (!jobId) {
89-
return `${process.env.GITHUB_SERVER_URL}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
90-
}
91-
92-
return `${process.env.GITHUB_SERVER_URL}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}/job/${jobId}`;
93-
}
94-
95-
const workflowUrl = await getWorkflowUrl(context.runId);
96-
core.exportVariable('WORKFLOW_URL', workflowUrl);
97-
core.exportVariable('GET_CONSOLE_LINK', `
98-
function getConsoleLink(prNumber) {
99-
return '🎮 [Control Plane Console](' +
100-
'https://console.cpln.io/console/org/' + process.env.CPLN_ORG + '/gvc/' + process.env.APP_NAME + '/-info)';
101-
}
102-
`);
139+
- name: Validate Deployment Request
140+
id: validate
141+
if: env.DO_DEPLOY != 'false'
142+
run: |
143+
if ! [[ "${{ github.event_name }}" == "workflow_dispatch" || \
144+
("${{ github.event_name }}" == "issue_comment" && "${{ github.event.comment.body }}" == "/deploy-review-app") || \
145+
"${{ github.event_name }}" == "pull_request" ]]; then
146+
echo "Skipping deployment - not a valid trigger (event: ${{ github.event_name }})"
147+
exit 1
148+
fi
103149
104150
- name: Create Initial Comment
105-
if: |
106-
(github.event_name == 'issue_comment' &&
107-
github.event.issue.pull_request &&
108-
github.event.comment.body == '/deploy-review-app') ||
109-
( steps.check-app.outputs.app_exists == 'true')
110-
id: create-comment
151+
if: env.DO_DEPLOY != 'false'
111152
uses: actions/github-script@v7
112153
with:
113154
script: |
114155
const result = await github.rest.issues.createComment({
115156
owner: context.repo.owner,
116157
repo: context.repo.repo,
117158
issue_number: process.env.PR_NUMBER,
118-
body: '🚀 Starting deployment process...'
159+
body: '🚀 Starting deployment process...\n\n' + process.env.CONSOLE_LINK
119160
});
120-
console.log('Created comment:', result.data.id);
121-
return { commentId: result.data.id };
161+
core.setOutput('comment-id', result.data.id);
122162
123-
- name: Set Comment ID
124-
if: |
125-
(github.event_name == 'issue_comment' &&
126-
github.event.issue.pull_request &&
127-
github.event.comment.body == '/deploy-review-app') ||
128-
(steps.check-app.outputs.app_exists == 'true')
129-
run: echo "COMMENT_ID=${{ fromJSON(steps.create-comment.outputs.result).commentId }}" >> $GITHUB_ENV
130-
131-
- name: Initialize Deployment
132-
id: init-deployment
163+
- name: Set Deployment URLs
164+
id: set-urls
165+
if: env.DO_DEPLOY != 'false'
133166
uses: actions/github-script@v7
134167
with:
135168
script: |
136-
async function getWorkflowUrl(runId) {
137-
const jobs = await github.rest.actions.listJobsForWorkflowRun({
169+
// Set workflow URL for logs
170+
const getWorkflowUrl = async (runId) => {
171+
const { data: run } = await github.rest.actions.getWorkflowRun({
138172
owner: context.repo.owner,
139173
repo: context.repo.repo,
140174
run_id: runId
141175
});
142-
143-
const currentJob = jobs.data.jobs.find(job => job.status === 'in_progress');
144-
const jobId = currentJob?.id;
145-
146-
if (!jobId) {
147-
console.log('Warning: Could not find current job ID');
148-
return `${process.env.GITHUB_SERVER_URL}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
149-
}
150-
151-
return `${process.env.GITHUB_SERVER_URL}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}/job/${jobId}`;
152-
}
153-
154-
// Create initial deployment comment
155-
const comment = await github.rest.issues.createComment({
156-
owner: context.repo.owner,
157-
repo: context.repo.repo,
158-
issue_number: process.env.PR_NUMBER,
159-
body: '⏳ Initializing deployment...'
160-
});
176+
return run.html_url;
177+
};
161178
162-
// Create GitHub deployment
163-
const deployment = await github.rest.repos.createDeployment({
164-
owner: context.repo.owner,
165-
repo: context.repo.repo,
166-
ref: context.sha,
167-
environment: 'review',
168-
auto_merge: false,
169-
required_contexts: []
170-
});
171-
172179
const workflowUrl = await getWorkflowUrl(context.runId);
173-
174-
return {
175-
deploymentId: deployment.data.id,
176-
commentId: comment.data.id,
177-
workflowUrl
178-
};
179-
180-
- name: Set comment ID and workflow URL
181-
run: |
182-
echo "COMMENT_ID=${{ fromJSON(steps.init-deployment.outputs.result).commentId }}" >> $GITHUB_ENV
183-
echo "WORKFLOW_URL=${{ fromJSON(steps.init-deployment.outputs.result).workflowUrl }}" >> $GITHUB_ENV
184-
185-
- name: Set commit hash
186-
run: |
187-
FULL_COMMIT="${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || steps.getRef.outputs.PR_SHA || github.sha }}"
188-
echo "COMMIT_HASH=${FULL_COMMIT:0:7}" >> $GITHUB_ENV
180+
core.exportVariable('WORKFLOW_URL', workflowUrl);
181+
core.exportVariable('CONSOLE_LINK',
182+
'🎮 [Control Plane Console](' +
183+
'https://console.cpln.io/console/org/' + process.env.CPLN_ORG_STAGING + '/gvc/' + process.env.APP_NAME + '/-info)'
184+
);
189185
190186
- name: Update Status - Building
191-
if: |
192-
(github.event_name == 'issue_comment' &&
193-
github.event.issue.pull_request &&
194-
github.event.comment.body == '/deploy-review-app') ||
195-
(steps.check-app.outputs.app_exists == 'true')
187+
if: env.DO_DEPLOY != 'false'
196188
uses: actions/github-script@v7
197189
with:
198190
script: |
199-
eval(process.env.GET_CONSOLE_LINK);
200-
201191
const buildingMessage = [
202192
'🏗️ Building Docker image for PR #' + process.env.PR_NUMBER + ', commit ' + '${{ env.COMMIT_HASH }}',
203-
'🏗️ Building Docker image...',
204193
'',
205194
'📝 [View Build Logs](' + process.env.WORKFLOW_URL + ')',
206195
'',
207-
getConsoleLink(process.env.PR_NUMBER)
196+
process.env.CONSOLE_LINK
208197
].join('\n');
209198
210199
await github.rest.issues.updateComment({
211200
owner: context.repo.owner,
212201
repo: context.repo.repo,
213-
comment_id: process.env.COMMENT_ID,
202+
comment_id: ${{ steps.create-comment.outputs.comment-id }},
214203
body: buildingMessage
215204
});
216205
217206
- name: Checkout PR Branch
218-
if: |
219-
(github.event_name == 'issue_comment' &&
220-
github.event.issue.pull_request &&
221-
github.event.comment.body == '/deploy-review-app') ||
222-
(steps.check-app.outputs.app_exists == 'true')
207+
if: env.DO_DEPLOY != 'false'
223208
run: git checkout ${{ steps.getRef.outputs.PR_REF }}
224209

225210
- name: Build Docker Image
226-
if: |
227-
(github.event_name == 'issue_comment' &&
228-
github.event.issue.pull_request &&
229-
github.event.comment.body == '/deploy-review-app') ||
230-
(steps.check-app.outputs.app_exists == 'true')
211+
if: env.DO_DEPLOY != 'false'
231212
uses: ./.github/actions/build-docker-image
232213
with:
233214
app_name: ${{ env.APP_NAME }}
234-
org: ${{ env.CPLN_ORG }}
215+
org: ${{ env.CPLN_ORG_STAGING }}
235216
commit: ${{ env.COMMIT_HASH }}
236217
PR_NUMBER: ${{ env.PR_NUMBER }}
237218

238219
- name: Update Status - Deploying
239-
if: |
240-
(github.event_name == 'issue_comment' &&
241-
github.event.issue.pull_request &&
242-
github.event.comment.body == '/deploy-review-app') ||
243-
(steps.check-app.outputs.app_exists == 'true')
220+
if: env.DO_DEPLOY != 'false'
244221
uses: actions/github-script@v7
245222
with:
246223
script: |
247-
eval(process.env.GET_CONSOLE_LINK);
248-
249224
const deployingMessage = [
250225
'🚀 Deploying to Control Plane...',
251226
'',
252227
'⏳ Waiting for deployment to be ready...',
253228
'',
254229
'📝 [View Deploy Logs](' + process.env.WORKFLOW_URL + ')',
255230
'',
256-
getConsoleLink(process.env.PR_NUMBER)
231+
process.env.CONSOLE_LINK
257232
].join('\n');
258233
259234
await github.rest.issues.updateComment({
260235
owner: context.repo.owner,
261236
repo: context.repo.repo,
262-
comment_id: process.env.COMMENT_ID,
237+
comment_id: ${{ steps.create-comment.outputs.comment-id }},
263238
body: deployingMessage
264239
});
265240
266241
- name: Deploy to Control Plane
267-
if: |
268-
(github.event_name == 'issue_comment' &&
269-
github.event.issue.pull_request &&
270-
github.event.comment.body == '/deploy-review-app') ||
271-
(steps.check-app.outputs.app_exists == 'true')
242+
if: env.DO_DEPLOY != 'false'
272243
uses: ./.github/actions/deploy-to-control-plane
273244
with:
274245
app_name: ${{ env.APP_NAME }}
275-
org: ${{ env.CPLN_ORG }}
246+
org: ${{ env.CPLN_ORG_STAGING }}
276247
github_token: ${{ secrets.GITHUB_TOKEN }}
277248
wait_timeout: ${{ vars.WAIT_TIMEOUT || 900 }}
278-
env:
279-
CPLN_TOKEN: ${{ env.CPLN_TOKEN }}
280-
PR_NUMBER: ${{ env.PR_NUMBER }}
249+
cpln_token: ${{ secrets.CPLN_TOKEN_STAGING }}
250+
pr_number: ${{ env.PR_NUMBER }}
281251

282252
- name: Update Status - Deployment Complete
253+
if: env.DO_DEPLOY != 'false'
283254
uses: actions/github-script@v7
284255
with:
285256
script: |
@@ -288,8 +259,7 @@ jobs:
288259
const workflowUrl = process.env.WORKFLOW_URL;
289260
const isSuccess = '${{ job.status }}' === 'success';
290261
291-
const consoleLink = '🎮 [Control Plane Console](https://console.cpln.io/console/org/' +
292-
process.env.CPLN_ORG + '/gvc/' + process.env.APP_NAME + '/-info)';
262+
const consoleLink = process.env.CONSOLE_LINK;
293263
294264
// Create GitHub deployment status
295265
const deploymentStatus = {
@@ -326,6 +296,6 @@ jobs:
326296
await github.rest.issues.updateComment({
327297
owner: context.repo.owner,
328298
repo: context.repo.repo,
329-
comment_id: process.env.COMMENT_ID,
299+
comment_id: ${{ steps.create-comment.outputs.comment-id }},
330300
body: isSuccess ? successMessage : failureMessage
331301
});

‎.github/workflows/help-command.yml‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ on:
77
issue_comment:
88
types: [created]
99
workflow_dispatch:
10+
inputs:
11+
issue-number:
12+
description: 'PR/Issue number to post the help comment to'
13+
required: true
14+
type: number
1015

1116
permissions:
1217
issues: write
@@ -25,7 +30,8 @@ jobs:
2530
- name: Checkout
2631
uses: actions/checkout
2732

28-
- name: Show Help Information
33+
- name: Process Help Command
2934
uses: ./.github/actions/help-command
3035
with:
3136
github-token: ${{ secrets.GITHUB_TOKEN }}
37+
issue-number: ${{ github.event.inputs.issue-number }}

0 commit comments

Comments
 (0)
Please sign in to comment.