@@ -111,74 +111,26 @@ jobs:
111
111
fi
112
112
113
113
# Check if app exists and save state
114
- echo "apple"
115
- echo "NoBrace: $(cpflow exists -a ${{ env.APP_NAME }})"
116
- echo "Brace: $([ cpflow exists -a ${{ env.APP_NAME }} ])"
117
114
if ! cpflow exists -a ${{ env.APP_NAME }}; then
118
- echo "review app does not exist!"
119
115
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
120
- echo "Canceling job as review app has not been previously deployed."; sleep inf
116
+ echo "Canceling job as review app has not been previously deployed."
121
117
fi
122
- echo "APP_EXISTS=false"
123
118
echo "APP_EXISTS=false" >> $GITHUB_ENV
124
- fi
125
- echo "bananas"
126
-
127
- - name : Validate Deployment Request
128
- id : validate
129
- run : |
130
- # Skip validation if deployment is already disabled
131
- if [[ "${{ env.DO_DEPLOY }}" == "false" ]]; then
132
- echo "Skipping validation - deployment already disabled"
133
- exit 0
134
- fi
135
-
136
- if ! [[ "${{ github.event_name }}" == "workflow_dispatch" || \
137
- "${{ github.event_name }}" == "issue_comment" || \
138
- "${{ github.event_name }}" == "pull_request" || \
139
- "${{ github.event_name }}" == "push" ]]; then
140
- echo "Error: Unsupported event type ${{ github.event_name }}"
141
- exit 1
142
- fi
143
-
144
- # Set DO_DEPLOY based on event type and conditions
145
- if [[ "${{ github.event_name }}" == "pull_request" && \
146
- ("${{ github.event.action }}" == "opened" || \
147
- "${{ github.event.action }}" == "synchronize" || \
148
- "${{ github.event.action }}" == "reopened") ]]; then
149
- echo "DO_DEPLOY=true" >> $GITHUB_ENV
150
- elif [[ "${{ github.event_name }}" == "push" ]]; then
151
- echo "DO_DEPLOY=true" >> $GITHUB_ENV
152
- elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
153
- echo "DO_DEPLOY=true" >> $GITHUB_ENV
154
- elif [[ "${{ github.event_name }}" == "issue_comment" ]]; then
155
- if [[ "${{ github.event.issue.pull_request }}" ]]; then
156
- # Trim spaces and check for exact command
157
- COMMENT_BODY=$(echo "${{ github.event.comment.body }}" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
158
- if [[ "$COMMENT_BODY" == "/deploy-review-app" ]]; then
159
- echo "DO_DEPLOY=true" >> $GITHUB_ENV
160
- else
161
- echo "DO_DEPLOY=false" >> $GITHUB_ENV
162
- echo "Skipping deployment - comment '$COMMENT_BODY' does not match '/deploy-review-app'"
163
- fi
164
- else
165
- echo "DO_DEPLOY=false" >> $GITHUB_ENV
166
- echo "Skipping deployment for non-PR comment"
167
- fi
168
- fi
169
- if [[ "${{ env.DO_DEPLOY }}" == "false" ]]; then
170
- exit 0
119
+ else
120
+ echo "APP_EXISTS=true" >> $GITHUB_ENV
171
121
fi
172
122
173
123
- name : Setup Control Plane App if Not Existing
174
- if : env.APP_EXISTS == 'false'
124
+ if : env.APP_EXISTS == 'false' && github.event_name != 'pull_request'
175
125
env :
176
126
CPLN_TOKEN : ${{ secrets.CPLN_TOKEN_STAGING }}
177
127
run : |
178
128
echo "🔧 Setting up new Control Plane app..."
179
129
cpflow setup-app -a ${{ env.APP_NAME }} --org ${{ vars.CPLN_ORG_STAGING }}
130
+ echo "APP_EXISTS=true" >> $GITHUB_ENV
180
131
181
132
- name : Create Initial Comment
133
+ if : env.APP_EXISTS == 'true'
182
134
uses : actions/github-script@v7
183
135
id : create-comment
184
136
with :
@@ -192,6 +144,7 @@ jobs:
192
144
core.setOutput('comment-id', result.data.id);
193
145
194
146
- name : Set Deployment URLs
147
+ if : env.APP_EXISTS == 'true'
195
148
id : set-urls
196
149
uses : actions/github-script@v7
197
150
with :
@@ -223,6 +176,7 @@ jobs:
223
176
);
224
177
225
178
- name : Initialize GitHub Deployment
179
+ if : env.APP_EXISTS == 'true'
226
180
uses : actions/github-script@v7
227
181
id : init-deployment
228
182
with :
@@ -252,6 +206,7 @@ jobs:
252
206
return deployment.data.id;
253
207
254
208
- name : Update Status - Building
209
+ if : env.APP_EXISTS == 'true'
255
210
uses : actions/github-script@v7
256
211
with :
257
212
script : |
@@ -271,6 +226,7 @@ jobs:
271
226
});
272
227
273
228
- name : Build Docker Image
229
+ if : env.APP_EXISTS == 'true'
274
230
id : build
275
231
uses : ./.github/actions/build-docker-image
276
232
with :
@@ -280,6 +236,7 @@ jobs:
280
236
PR_NUMBER : ${{ env.PR_NUMBER }}
281
237
282
238
- name : Update Status - Deploying
239
+ if : env.APP_EXISTS == 'true'
283
240
uses : actions/github-script@v7
284
241
with :
285
242
script : |
@@ -301,13 +258,16 @@ jobs:
301
258
});
302
259
303
260
- name : Deploy to Control Plane
261
+ if : env.APP_EXISTS == 'true'
304
262
run : cpflow deploy-image -a ${{ env.APP_NAME }} --run-release-phase --org ${{ vars.CPLN_ORG_STAGING }} --verbose
305
263
306
264
- name : Retrieve App URL
265
+ if : env.APP_EXISTS == 'true'
307
266
id : workload
308
267
run : echo "WORKLOAD_URL=$(cpln workload get rails --gvc ${{ env.APP_NAME }} | tee | grep -oP 'https://[^[:space:]]*\.cpln\.app(?=\s|$)' | head -n1)" >> "$GITHUB_OUTPUT"
309
268
310
269
- name : Update Status - Deployment Complete
270
+ if : env.APP_EXISTS == 'true'
311
271
uses : actions/github-script@v7
312
272
with :
313
273
script : |
0 commit comments