@@ -141,35 +141,48 @@ jobs:
141
141
org : ${{ env.CPLN_ORG }}
142
142
github_token : ${{ secrets.GITHUB_TOKEN }}
143
143
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
-
151
144
- name : Update PR commit message
152
145
if : success()
153
146
env :
154
147
GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
148
+ RAILS_URL : ${{ steps.deploy.outputs.rails_url }}
155
149
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 "[email protected] "
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 "[email protected] "
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
162
172
163
173
- name : Update deployment status success
164
174
if : success()
165
175
uses : actions/github-script@v7
176
+ env :
177
+ RAILS_URL : ${{ steps.deploy.outputs.rails_url }}
166
178
with :
167
179
script : |
168
180
const message = `✅ Deployment successful!
181
+
169
182
Environment: review-app
170
183
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}`;
173
186
174
187
await github.rest.issues.createComment({
175
188
issue_number: context.issue.number || context.payload.pull_request.number,
@@ -183,18 +196,21 @@ jobs:
183
196
repo: context.repo.repo,
184
197
deployment_id: ${{ steps.create-deployment.outputs.result }},
185
198
state: 'success',
186
- environment_url: '${{ env.RAILS_URL }}' ,
187
- description: 'Deployment successful'
199
+ environment_url: process. env.RAILS_URL,
200
+ description: '✅ Deployment successful'
188
201
});
189
202
190
203
- name : Update deployment status failure
191
204
if : failure()
192
205
uses : actions/github-script@v7
206
+ env :
207
+ RAILS_URL : ${{ steps.deploy.outputs.rails_url }}
193
208
with :
194
209
script : |
195
210
const message = `❌ Deployment failed
211
+
196
212
Commit: ${context.sha.substring(0, 7)}
197
- Status: ${process.env.statusUrl}`;
213
+ Workflow Status: ${process.env.statusUrl}`;
198
214
199
215
await github.rest.issues.createComment({
200
216
issue_number: context.issue.number || context.payload.pull_request.number,
@@ -208,5 +224,5 @@ jobs:
208
224
repo: context.repo.repo,
209
225
deployment_id: ${{ steps.create-deployment.outputs.result }},
210
226
state: 'failure',
211
- description: 'Deployment failed'
227
+ description: '❌ Deployment failed'
212
228
});
0 commit comments