Skip to content

Commit 29ade6f

Browse files
committed
Fixes
1 parent e26cc72 commit 29ade6f

File tree

2 files changed

+39
-29
lines changed

2 files changed

+39
-29
lines changed

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

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,17 @@ runs:
7171
id: deploy
7272
shell: bash
7373
run: |
74+
# Debug git commit information
75+
echo "🔍 Debugging git commit information:"
76+
echo "Current directory: $(pwd)"
77+
echo "Git status:"
78+
git status
79+
echo "Git log (last 5 commits):"
80+
git log -n 5 --oneline
81+
echo "steps.get_sha.outputs.sha_short: ${{steps.get_sha.outputs.sha_short}}"
82+
echo "Full SHA from git rev-parse HEAD: $(git rev-parse HEAD)"
83+
echo "Short SHA from git rev-parse --short HEAD: $(git rev-parse --short HEAD)"
84+
7485
# Deploy rails workload
7586
echo "🚀 Starting deployment process..."
7687
echo "📦 Building image with commit SHA: ${{steps.get_sha.outputs.sha_short}}"
@@ -81,21 +92,15 @@ runs:
8192
# Run the command and tee output to both stdout and temp file
8293
set -o pipefail # Make sure we get the correct exit code from the cpln command
8394
84-
echo "🔄 Updating Rails workload..."
85-
if cpln workload update rails --gvc ${{ inputs.app_name }} --org ${{ inputs.org }} --set spec.containers.rails.image=/org/${{ inputs.org }}/image/${{ inputs.app_name }}:${{steps.get_sha.outputs.sha_short}} | tee "$TEMP_OUTPUT"; then
95+
echo "🔄 Building and deploying with cpflow..."
96+
if cpflow build-image -a ${{ inputs.app_name }} --commit=${{steps.get_sha.outputs.sha_short}} --org=${{inputs.org}} | tee "$TEMP_OUTPUT" && \
97+
cpflow deploy-image -a ${{ inputs.app_name }} --run-release-phase --org ${{inputs.org}} --verbose | tee -a "$TEMP_OUTPUT"; then
98+
8699
# Extract the URL from the deployment output
87100
RAILS_URL=$(grep -o 'https://rails-[^[:space:]]*\.cpln\.app' "$TEMP_OUTPUT" || true)
88101
if [ -n "$RAILS_URL" ]; then
89102
echo "🌐 Found Rails deployment URL: $RAILS_URL"
90103
echo "rails_url=$RAILS_URL" >> $GITHUB_OUTPUT
91-
92-
echo "🔄 Updating daily-task workload..."
93-
if cpln workload update daily-task --gvc ${{ inputs.app_name }} --org ${{ inputs.org }} --set spec.containers.daily-task.image=/org/${{ inputs.org }}/image/${{ inputs.app_name }}:${{steps.get_sha.outputs.sha_short}} | tee "$TEMP_OUTPUT"; then
94-
echo "✅ Both workloads updated successfully!"
95-
else
96-
echo "⚠️ Daily-task update failed, but Rails deployment was successful"
97-
fi
98-
99104
rm "$TEMP_OUTPUT"
100105
else
101106
rm "$TEMP_OUTPUT"
@@ -104,6 +109,6 @@ runs:
104109
fi
105110
else
106111
rm "$TEMP_OUTPUT"
107-
echo "❌ Rails deployment failed"
112+
echo "❌ Deployment command failed"
108113
exit 1
109114
fi

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

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ env:
1919

2020
jobs:
2121
check-concurrent:
22+
name: Deploy Review App to Control Plane / check-concurrent
2223
runs-on: ubuntu-latest
2324
outputs:
2425
cancelled: ${{ steps.check.outputs.cancelled }}
@@ -55,35 +56,34 @@ jobs:
5556

5657
steps:
5758
- name: Create initial comment and get job URL
58-
id: init
59+
id: create-comment
5960
uses: actions/github-script@v7
6061
with:
6162
script: |
62-
// Get the job ID from the Actions API
63-
const { data: jobs } = await github.rest.actions.listJobsForWorkflowRun({
63+
const currentJob = await github.rest.actions.getJobForWorkflowRun({
6464
owner: context.repo.owner,
6565
repo: context.repo.repo,
66-
run_id: context.runId,
67-
});
68-
69-
const currentJob = jobs.jobs.find(job => job.name === context.job);
70-
if (!currentJob) {
71-
throw new Error('Could not find current job in the workflow run');
72-
}
66+
job_id: context.runId
67+
}).then(response => response.data);
7368
7469
const statusUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}/job/${currentJob.id}?pr=${context.issue.number || context.payload.pull_request.number}`;
7570
core.exportVariable('statusUrl', statusUrl);
7671
77-
const message = "🚀 Starting new deployment for commit: " + context.sha.substring(0, 7) +
72+
const deploymentId = Date.now().toString();
73+
core.exportVariable('deploymentId', deploymentId);
74+
75+
const message = "🚀 Starting new deployment [" + deploymentId + "] for commit: " + context.sha.substring(0, 7) +
7876
"\nChanges: " + (context.payload.commits ? context.payload.commits[0].message : '') +
7977
"\nStatus: " + statusUrl;
8078
81-
await github.rest.issues.createComment({
79+
const comment = await github.rest.issues.createComment({
8280
issue_number: context.issue.number || context.payload.pull_request.number,
8381
owner: context.repo.owner,
8482
repo: context.repo.repo,
8583
body: message
8684
});
85+
86+
core.setOutput('comment-id', comment.data.id);
8787
8888
- name: Create GitHub Deployment
8989
id: create-deployment
@@ -146,14 +146,16 @@ jobs:
146146
uses: actions/github-script@v7
147147
env:
148148
RAILS_URL: ${{ steps.deploy.outputs.rails_url }}
149+
COMMENT_ID: ${{ steps.create-comment.outputs.comment-id }}
150+
DEPLOYMENT_ID: ${{ env.deploymentId }}
149151
with:
150152
script: |
151-
const message = "✅ Deployment successful!\n\n🚀 Rails app: " + process.env.RAILS_URL + "\n📊 Status: " + process.env.statusUrl;
153+
const message = "✅ Deployment [" + process.env.DEPLOYMENT_ID + "] successful!\n\n🚀 Rails app: " + process.env.RAILS_URL + "\n📊 Status: " + process.env.statusUrl;
152154
153-
await github.rest.issues.createComment({
154-
issue_number: context.issue.number || context.payload.pull_request.number,
155+
await github.rest.issues.updateComment({
155156
owner: context.repo.owner,
156157
repo: context.repo.repo,
158+
comment_id: process.env.COMMENT_ID,
157159
body: message
158160
});
159161
@@ -169,14 +171,17 @@ jobs:
169171
- name: Post deployment failure
170172
if: failure()
171173
uses: actions/github-script@v7
174+
env:
175+
COMMENT_ID: ${{ steps.create-comment.outputs.comment-id }}
176+
DEPLOYMENT_ID: ${{ env.deploymentId }}
172177
with:
173178
script: |
174-
const message = "❌ Deployment failed\n\nCommit: " + context.sha.substring(0, 7) + "\nWorkflow Status: " + process.env.statusUrl;
179+
const message = "❌ Deployment [" + process.env.DEPLOYMENT_ID + "] failed\n\nCommit: " + context.sha.substring(0, 7) + "\nWorkflow Status: " + process.env.statusUrl;
175180
176-
await github.rest.issues.createComment({
177-
issue_number: context.issue.number || context.payload.pull_request.number,
181+
await github.rest.issues.updateComment({
178182
owner: context.repo.owner,
179183
repo: context.repo.repo,
184+
comment_id: process.env.COMMENT_ID,
180185
body: message
181186
});
182187

0 commit comments

Comments
 (0)