11name : Deploy to Control Plane
22
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) }}"
44
55on :
66 pull_request :
@@ -114,8 +114,18 @@ jobs:
114114
115115 - name : Setup cpflow app
116116 run : |
117+ set -e
118+
119+ # Validate required environment variables
120+ : "${APP_NAME:?APP_NAME environment variable is required}"
121+
117122 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"
119129 fi
120130
121131 - name : Deploy to Control Plane
@@ -135,9 +145,10 @@ jobs:
135145 with :
136146 script : |
137147 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;
141152 const railsUrl = '${{ steps.deploy.outputs.rails_url }}';
142153 const prNumber = process.env.PR_NUMBER;
143154
@@ -154,7 +165,12 @@ jobs:
154165 deploymentStatus.environment_url = railsUrl;
155166 }
156167
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+ }
158174
159175 // Update the initial comment
160176 const successMessage = [
@@ -173,9 +189,14 @@ jobs:
173189 '[View Workflow Status](' + workflowUrl + ')'
174190 ].join('\n');
175191
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