Skip to content

Commit 3fe506e

Browse files
committed
fixes
1 parent 895986c commit 3fe506e

File tree

2 files changed

+24
-38
lines changed

2 files changed

+24
-38
lines changed

.github/actions/build-docker-image/action.yml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,11 @@ runs:
1919
id: build
2020
shell: bash
2121
run: |
22-
# Redirect build output to a log file to keep Actions log clean
23-
LOG_FILE=$(mktemp)
24-
echo "🏗️ Building Docker image for commit ${{ inputs.commit }}... (detailed logs will be shown at the end if there's an error)"
22+
echo "🏗️ Building Docker image for commit ${{ inputs.commit }}..."
2523
26-
if cpflow build-image -a ${{ inputs.app_name }} --commit=${{ inputs.commit }} --org=${{ inputs.org }} > "$LOG_FILE" 2>&1; then
24+
if cpflow build-image -a ${{ inputs.app_name }} --commit=${{ inputs.commit }} --org=${{ inputs.org }}; then
2725
echo "✅ Docker image build successful for commit ${{ inputs.commit }}"
2826
else
29-
BUILD_EXIT_CODE=$?
3027
echo "❌ Docker image build failed for commit ${{ inputs.commit }}"
31-
echo "==== Build Logs ===="
32-
cat "$LOG_FILE"
33-
rm -f "$LOG_FILE"
34-
exit $BUILD_EXIT_CODE
28+
exit 1
3529
fi
36-
rm -f "$LOG_FILE"

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

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ jobs:
3939
if: github.event_name == 'issue_comment'
4040
id: getRef
4141
run: |
42-
echo "PR_REF=$(gh pr view $PR_NUMBER --repo ${{ github.repository }} --json headRefName | jq -r '.headRefName')" >> $GITHUB_OUTPUT
43-
echo "PR_SHA=$(gh pr view $PR_NUMBER --repo ${{ github.repository }} --json headRefOid | jq -r '.headRefOid')" >> $GITHUB_OUTPUT
42+
# For PR comments, get the actual PR head commit
43+
PR_DATA=$(gh pr view $PR_NUMBER --repo ${{ github.repository }} --json headRefName,headRefOid)
44+
echo "PR_REF=$(echo "$PR_DATA" | jq -r '.headRefName')" >> $GITHUB_OUTPUT
45+
echo "PR_SHA=$(echo "$PR_DATA" | jq -r '.headRefOid')" >> $GITHUB_OUTPUT
4446
env:
4547
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4648

@@ -56,7 +58,10 @@ jobs:
5658
- uses: actions/checkout@v4
5759
with:
5860
fetch-depth: 0
59-
ref: ${{ steps.getRef.outputs.PR_REF || github.ref }}
61+
# For PR events: use the head SHA
62+
# For PR comments: use the PR head SHA
63+
# For other events: use the push SHA
64+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || steps.getRef.outputs.PR_SHA || github.sha }}
6065

6166
- name: Setup Environment
6267
uses: ./.github/actions/setup-environment
@@ -158,7 +163,8 @@ jobs:
158163
with:
159164
app_name: ${{ env.APP_NAME }}
160165
org: ${{ env.CPLN_ORG }}
161-
commit: ${{ github.event.comment.body && steps.getRef.outputs.PR_SHA || github.sha }}
166+
# Use the same commit resolution as checkout
167+
commit: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || steps.getRef.outputs.PR_SHA || github.sha }}
162168

163169
- name: Deploy to Control Plane
164170
if: steps.determine_action.outputs.action == 'deploy'
@@ -181,7 +187,6 @@ jobs:
181187
const workflowUrl = result.workflowUrl;
182188
const railsUrl = '${{ steps.deploy.outputs.rails_url }}';
183189
const prNumber = process.env.PR_NUMBER;
184-
const commitSha = '${{ github.event.comment.body && steps.getRef.outputs.PR_SHA || github.sha }}';
185190
186191
// Update deployment status
187192
const deploymentStatus = {
@@ -196,40 +201,28 @@ jobs:
196201
deploymentStatus.environment_url = railsUrl;
197202
}
198203
199-
try {
200-
await github.rest.repos.createDeploymentStatus(deploymentStatus);
201-
} catch (error) {
202-
console.error('Failed to update deployment status:', error);
203-
throw error;
204-
}
204+
await github.rest.repos.createDeploymentStatus(deploymentStatus);
205205
206206
// Update the initial comment
207207
const successMessage = [
208-
'🚀 Rails App Deployed to Control Plane for Commit ' + commitSha.substring(0, 7),
208+
'✅ Deployment successful for PR #' + prNumber,
209209
'',
210-
'🌐 Rails App: [' + railsUrl + '](' + railsUrl + ')',
210+
'🚀 [Deployed Review App](' + railsUrl + ')',
211211
'',
212-
'⚡ [Control Plane Console for Review App](https://console.cpln.io/console/org/' + process.env.CPLN_ORG + '/gvc/' + process.env.APP_NAME + '/workload)',
212+
'⚡ [Control Plane Console](https://console.cpln.io/console/org/' + process.env.CPLN_ORG + '/gvc/' + process.env.APP_NAME + '/workload)',
213213
'',
214214
'[View Workflow Status](' + workflowUrl + ')'
215215
].join('\n');
216216
217217
const failureMessage = [
218-
'❌ Deployment failed for PR ' + prNumber,
219-
'',
220-
'Commit: ' + commitSha.substring(0, 7),
218+
'❌ Deployment failed for PR #' + prNumber,
221219
'',
222220
'[View Workflow Status](' + workflowUrl + ')'
223221
].join('\n');
224222
225-
try {
226-
await github.rest.issues.updateComment({
227-
owner: context.repo.owner,
228-
repo: context.repo.repo,
229-
comment_id: commentId,
230-
body: isSuccess ? successMessage : failureMessage
231-
});
232-
} catch (error) {
233-
console.error('Failed to update comment:', error);
234-
throw error;
235-
}
223+
await github.rest.issues.updateComment({
224+
owner: context.repo.owner,
225+
repo: context.repo.repo,
226+
comment_id: commentId,
227+
body: isSuccess ? successMessage : failureMessage
228+
});

0 commit comments

Comments
 (0)