2525 - name : Setup Environment
2626 uses : ./.github/actions/setup-environment
2727
28- - name : Get commit SHA
28+ - name : Get Commit SHA
2929 id : get_sha
3030 shell : bash
3131 run : |
@@ -46,22 +46,69 @@ runs:
4646 GITHUB_TOKEN : ${{ inputs.github_token }}
4747 PR_NUMBER : ${{ env.PR_NUMBER }}
4848
49- - name : Build Image
49+ - name : Initialize Deployment
50+ id : init-deployment
51+ uses : actions/github-script@v7
52+ with :
53+ script : |
54+ // Create GitHub deployment
55+ const deployment = await github.rest.repos.createDeployment({
56+ owner: context.repo.owner,
57+ repo: context.repo.repo,
58+ ref: context.sha,
59+ environment: 'review-app',
60+ auto_merge: false,
61+ required_contexts: []
62+ });
63+
64+ const prNumber = context.issue.number || context.payload.pull_request.number;
65+
66+ // Get the job ID from the workflow run
67+ const jobs = await github.rest.actions.listJobsForWorkflowRun({
68+ owner: context.repo.owner,
69+ repo: context.repo.repo,
70+ run_id: context.runId
71+ });
72+
73+ const jobId = jobs.data.jobs.find(job => job.name === 'deploy')?.id;
74+
75+ // Create initial comment
76+ const comment = await github.rest.issues.createComment({
77+ issue_number: prNumber,
78+ owner: context.repo.owner,
79+ repo: context.repo.repo,
80+ body: `🚀 Starting deployment for PR ${prNumber}\nDeployment Log: ${process.env.GITHUB_SERVER_URL}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}/job/${jobId}?pr=${prNumber}`
81+ });
82+
83+ // Set deployment status to in_progress
84+ await github.rest.repos.createDeploymentStatus({
85+ owner: context.repo.owner,
86+ repo: context.repo.repo,
87+ deployment_id: deployment.data.id,
88+ state: 'in_progress',
89+ description: 'Deployment is in progress'
90+ });
91+
92+ return {
93+ deploymentId: deployment.data.id,
94+ commentId: comment.data.id
95+ };
96+
97+ - name : Build Docker Image
5098 id : build
5199 shell : bash
52100 run : |
53- echo "🏗️ Building image with commit: ${{steps.get_sha.outputs.sha_short}} "
54- cpflow build-image -a ${{ inputs.app_name }} --commit=${{steps.get_sha.outputs.sha_short }} --org=${{inputs.org}}
101+ echo "🏗️ Building Docker image... "
102+ cpflow build-image -a ${{ inputs.app_name }} --commit=${{ github.sha }} --org=${{ inputs.org }}
55103
56- - name : Deploy Image
104+ - name : Deploy to Control Plane
57105 id : deploy
58106 shell : bash
59107 run : |
60- # Create temp file for output
108+ echo "🚀 Deploying to Control Plane..."
61109 TEMP_OUTPUT=$(mktemp)
62110
63- echo "🚀 Deploying image..."
64- if cpflow deploy-image -a ${{ inputs.app_name }} --run-release-phase --org ${{inputs.org}} --verbose | tee "$TEMP_OUTPUT"; then
111+ if cpflow deploy-image -a ${{ inputs.app_name }} --run-release-phase --org ${{ inputs.org }} --verbose | tee "$TEMP_OUTPUT"; then
65112 # Extract Rails URL
66113 RAILS_URL=$(grep -o 'https://rails-[^[:space:]]*\.cpln\.app' "$TEMP_OUTPUT")
67114 if [ -n "$RAILS_URL" ]; then
0 commit comments