@@ -141,35 +141,48 @@ jobs:
141141 org : ${{ env.CPLN_ORG }}
142142 github_token : ${{ secrets.GITHUB_TOKEN }}
143143
144- - name : Extract deployment URL
145- id : extract-url
146- run : |
147- RAILS_URL=$(echo "${{ steps.deploy.outputs.deployment_output }}" | grep -o 'https://rails-[^[:space:]]*\.cpln\.app')
148- echo "RAILS_URL=$RAILS_URL" >> $GITHUB_ENV
149- echo "rails_url=$RAILS_URL" >> $GITHUB_OUTPUT
150-
151144 - name : Update PR commit message
152145 if : success()
153146 env :
154147 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
148+ RAILS_URL : ${{ steps.deploy.outputs.rails_url }}
155149 run : |
156- PR_SHA=$(gh pr view ${{ env.PR_NUMBER }} --json commits --jq '.commits[-1].oid')
157- git config user.name "GitHub Actions"
158- git config user.email "actions@github.com"
159- git pull --rebase
160- git commit --amend -m "Rails review app deployed to ${{ env.RAILS_URL }}"
161- git push --force-with-lease origin HEAD
150+ if [ -n "$RAILS_URL" ]; then
151+ echo "🔄 Updating PR commit message with deployment URL..."
152+ PR_SHA=$(gh pr view ${{ env.PR_NUMBER }} --json commits --jq '.commits[-1].oid')
153+ if [ -n "$PR_SHA" ]; then
154+ git config user.name "GitHub Actions"
155+ git config user.email "actions@github.com"
156+ git pull --rebase
157+ git commit --amend -m "Rails review app deployed to $RAILS_URL"
158+ if git push --force-with-lease origin HEAD; then
159+ echo "✅ Successfully updated commit message"
160+ else
161+ echo "❌ Failed to push updated commit message"
162+ exit 1
163+ fi
164+ else
165+ echo "❌ Failed to get PR SHA"
166+ exit 1
167+ fi
168+ else
169+ echo "❌ No Rails URL found in deployment output"
170+ exit 1
171+ fi
162172
163173 - name : Update deployment status success
164174 if : success()
165175 uses : actions/github-script@v7
176+ env :
177+ RAILS_URL : ${{ steps.deploy.outputs.rails_url }}
166178 with :
167179 script : |
168180 const message = `✅ Deployment successful!
181+
169182 Environment: review-app
170183 Commit: ${context.sha.substring(0, 7)}
171- URL: ${{ env.RAILS_URL } }
172- Status: ${process.env.statusUrl}`;
184+ Rails URL: ${process. env.RAILS_URL}
185+ Workflow Status: ${process.env.statusUrl}`;
173186
174187 await github.rest.issues.createComment({
175188 issue_number: context.issue.number || context.payload.pull_request.number,
@@ -183,18 +196,21 @@ jobs:
183196 repo: context.repo.repo,
184197 deployment_id: ${{ steps.create-deployment.outputs.result }},
185198 state: 'success',
186- environment_url: '${{ env.RAILS_URL }}' ,
187- description: 'Deployment successful'
199+ environment_url: process. env.RAILS_URL,
200+ description: '✅ Deployment successful'
188201 });
189202
190203 - name : Update deployment status failure
191204 if : failure()
192205 uses : actions/github-script@v7
206+ env :
207+ RAILS_URL : ${{ steps.deploy.outputs.rails_url }}
193208 with :
194209 script : |
195210 const message = `❌ Deployment failed
211+
196212 Commit: ${context.sha.substring(0, 7)}
197- Status: ${process.env.statusUrl}`;
213+ Workflow Status: ${process.env.statusUrl}`;
198214
199215 await github.rest.issues.createComment({
200216 issue_number: context.issue.number || context.payload.pull_request.number,
@@ -208,5 +224,5 @@ jobs:
208224 repo: context.repo.repo,
209225 deployment_id: ${{ steps.create-deployment.outputs.result }},
210226 state: 'failure',
211- description: 'Deployment failed'
227+ description: '❌ Deployment failed'
212228 });
0 commit comments