1
1
name : Deploy to Control Plane
2
2
3
- run-name : ${{ github.event_name == 'pull_request' || (github.event_name == 'issue_comment' && github.event.issue.pull_request) ? 'Deploying Review App' : format('Deploying {0} to Staging App', github.ref_name) }}
3
+ run-name : " ${{ github.event_name == 'pull_request' || (github.event_name == 'issue_comment' && github.event.issue.pull_request) ? 'Deploying Review App' : format('Deploying {0} to Staging App', github.ref_name) }}"
4
4
5
5
on :
6
6
pull_request :
@@ -114,8 +114,18 @@ jobs:
114
114
115
115
- name : Setup cpflow app
116
116
run : |
117
+ set -e
118
+
119
+ # Validate required environment variables
120
+ : "${APP_NAME:?APP_NAME environment variable is required}"
121
+
117
122
if ! cpflow exists -a ${{ env.APP_NAME }} ; then
118
- cpflow setup-app -a ${{ env.APP_NAME }}
123
+ echo "🔧 Setting up new application: ${{ env.APP_NAME }}"
124
+ if ! cpflow setup-app -a ${{ env.APP_NAME }}; then
125
+ echo "❌ Failed to setup application"
126
+ exit 1
127
+ fi
128
+ echo "✅ Application setup complete"
119
129
fi
120
130
121
131
- name : Deploy to Control Plane
@@ -135,9 +145,10 @@ jobs:
135
145
with :
136
146
script : |
137
147
const isSuccess = '${{ job.status }}' === 'success';
138
- const deploymentId = ${{ fromJSON(steps.init-deployment.outputs.result).deploymentId }};
139
- const commentId = ${{ fromJSON(steps.init-deployment.outputs.result).commentId }};
140
- const workflowUrl = ${{ fromJSON(steps.init-deployment.outputs.result).workflowUrl }};
148
+ const result = ${{ steps.init-deployment.outputs.result }};
149
+ const deploymentId = result.deploymentId;
150
+ const commentId = result.commentId;
151
+ const workflowUrl = result.workflowUrl;
141
152
const railsUrl = '${{ steps.deploy.outputs.rails_url }}';
142
153
const prNumber = process.env.PR_NUMBER;
143
154
@@ -154,7 +165,12 @@ jobs:
154
165
deploymentStatus.environment_url = railsUrl;
155
166
}
156
167
157
- await github.rest.repos.createDeploymentStatus(deploymentStatus);
168
+ try {
169
+ await github.rest.repos.createDeploymentStatus(deploymentStatus);
170
+ } catch (error) {
171
+ console.error('Failed to update deployment status:', error);
172
+ throw error;
173
+ }
158
174
159
175
// Update the initial comment
160
176
const successMessage = [
@@ -173,9 +189,14 @@ jobs:
173
189
'[View Workflow Status](' + workflowUrl + ')'
174
190
].join('\n');
175
191
176
- await github.rest.issues.updateComment({
177
- owner: context.repo.owner,
178
- repo: context.repo.repo,
179
- comment_id: commentId,
180
- body: isSuccess ? successMessage : failureMessage
181
- });
192
+ try {
193
+ await github.rest.issues.updateComment({
194
+ owner: context.repo.owner,
195
+ repo: context.repo.repo,
196
+ comment_id: commentId,
197
+ body: isSuccess ? successMessage : failureMessage
198
+ });
199
+ } catch (error) {
200
+ console.error('Failed to update comment:', error);
201
+ throw error;
202
+ }
0 commit comments