Skip to content

Commit f168a9b

Browse files
committed
fix-missing-url
1 parent a4b0353 commit f168a9b

File tree

1 file changed

+28
-30
lines changed

1 file changed

+28
-30
lines changed

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

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -43,32 +43,30 @@ jobs:
4343
- name: Setup Environment
4444
uses: ./.github/actions/setup-environment
4545

46-
- name: Get PR Number for Push Event
47-
if: github.event_name == 'push'
48-
id: get-pr
49-
env:
50-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
- name: Set PR Number for Comment Event
47+
if: |
48+
(github.event_name == 'issue_comment' &&
49+
github.event.issue.pull_request &&
50+
github.event.comment.body == '/deploy-review-app') ||
51+
github.event_name == 'push'
5152
run: |
52-
# Get PR number from branch
53-
PR_NUMBER=$(gh pr list --head ${{ github.ref_name }} --json number --jq '.[0].number')
54-
if [ -n "$PR_NUMBER" ]; then
55-
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
56-
echo "APP_NAME=qa-react-webpack-rails-tutorial-pr-$PR_NUMBER" >> $GITHUB_ENV
57-
echo "has_pr=true" >> $GITHUB_OUTPUT
53+
if [ "${{ github.event_name }}" = "issue_comment" ]; then
54+
echo "PR_NUMBER=${{ github.event.issue.number }}" >> $GITHUB_ENV
55+
echo "APP_NAME=qa-react-webpack-rails-tutorial-pr-${{ github.event.issue.number }}" >> $GITHUB_ENV
5856
else
59-
echo "No PR found for this branch"
60-
exit 0
57+
# For push events, get PR number from branch
58+
PR_NUMBER=$(gh pr list --head ${{ github.ref_name }} --json number --jq '.[0].number')
59+
if [ -n "$PR_NUMBER" ]; then
60+
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
61+
echo "APP_NAME=qa-react-webpack-rails-tutorial-pr-$PR_NUMBER" >> $GITHUB_ENV
62+
fi
6163
fi
62-
63-
- name: Set PR Number for Comment Event
64-
if: github.event_name == 'issue_comment'
65-
run: |
66-
echo "PR_NUMBER=${{ github.event.issue.number }}" >> $GITHUB_ENV
67-
echo "APP_NAME=qa-react-webpack-rails-tutorial-pr-${{ github.event.issue.number }}" >> $GITHUB_ENV
64+
env:
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6866

6967
- name: Check if Review App Exists
7068
id: check-app
71-
if: github.event_name == 'push' && steps.get-pr.outputs.has_pr == 'true'
69+
if: github.event_name == 'push' && github.event_name != 'issue_comment'
7270
env:
7371
CPLN_TOKEN: ${{ secrets.CPLN_TOKEN }}
7472
run: |
@@ -84,7 +82,7 @@ jobs:
8482
(github.event_name == 'issue_comment' &&
8583
github.event.issue.pull_request &&
8684
github.event.comment.body == '/deploy-review-app') ||
87-
(steps.get-pr.outputs.has_pr == 'true' && steps.check-app.outputs.app_exists == 'true')
85+
(github.event_name == 'push' && steps.check-app.outputs.app_exists == 'true')
8886
run: |
8987
PR_DATA=$(gh pr view ${{ env.PR_NUMBER }} --repo ${{ github.repository }} --json headRefName,headRefOid)
9088
echo "PR_REF=$(echo "$PR_DATA" | jq -r '.headRefName')" >> $GITHUB_OUTPUT
@@ -97,7 +95,7 @@ jobs:
9795
(github.event_name == 'issue_comment' &&
9896
github.event.issue.pull_request &&
9997
github.event.comment.body == '/deploy-review-app') ||
100-
(steps.get-pr.outputs.has_pr == 'true' && steps.check-app.outputs.app_exists == 'true')
98+
(github.event_name == 'push' && steps.check-app.outputs.app_exists == 'true')
10199
id: create-comment
102100
uses: actions/github-script@v7
103101
with:
@@ -116,15 +114,15 @@ jobs:
116114
(github.event_name == 'issue_comment' &&
117115
github.event.issue.pull_request &&
118116
github.event.comment.body == '/deploy-review-app') ||
119-
(steps.get-pr.outputs.has_pr == 'true' && steps.check-app.outputs.app_exists == 'true')
117+
(github.event_name == 'push' && steps.check-app.outputs.app_exists == 'true')
120118
run: echo "COMMENT_ID=${{ fromJSON(steps.create-comment.outputs.result).commentId }}" >> $GITHUB_ENV
121119

122120
- name: Set Workflow URL
123121
if: |
124122
(github.event_name == 'issue_comment' &&
125123
github.event.issue.pull_request &&
126124
github.event.comment.body == '/deploy-review-app') ||
127-
(steps.get-pr.outputs.has_pr == 'true' && steps.check-app.outputs.app_exists == 'true')
125+
(github.event_name == 'push' && steps.check-app.outputs.app_exists == 'true')
128126
id: workflow-url
129127
uses: actions/github-script@v7
130128
with:
@@ -154,7 +152,7 @@ jobs:
154152
(github.event_name == 'issue_comment' &&
155153
github.event.issue.pull_request &&
156154
github.event.comment.body == '/deploy-review-app') ||
157-
(steps.get-pr.outputs.has_pr == 'true' && steps.check-app.outputs.app_exists == 'true')
155+
(github.event_name == 'push' && steps.check-app.outputs.app_exists == 'true')
158156
uses: actions/github-script@v7
159157
with:
160158
script: |
@@ -167,7 +165,7 @@ jobs:
167165
(github.event_name == 'issue_comment' &&
168166
github.event.issue.pull_request &&
169167
github.event.comment.body == '/deploy-review-app') ||
170-
(steps.get-pr.outputs.has_pr == 'true' && steps.check-app.outputs.app_exists == 'true')
168+
(github.event_name == 'push' && steps.check-app.outputs.app_exists == 'true')
171169
uses: actions/github-script@v7
172170
with:
173171
script: |
@@ -191,15 +189,15 @@ jobs:
191189
(github.event_name == 'issue_comment' &&
192190
github.event.issue.pull_request &&
193191
github.event.comment.body == '/deploy-review-app') ||
194-
(steps.get-pr.outputs.has_pr == 'true' && steps.check-app.outputs.app_exists == 'true')
192+
(github.event_name == 'push' && steps.check-app.outputs.app_exists == 'true')
195193
run: git checkout ${{ steps.getRef.outputs.PR_REF }}
196194

197195
- name: Build Docker Image
198196
if: |
199197
(github.event_name == 'issue_comment' &&
200198
github.event.issue.pull_request &&
201199
github.event.comment.body == '/deploy-review-app') ||
202-
(steps.get-pr.outputs.has_pr == 'true' && steps.check-app.outputs.app_exists == 'true')
200+
(github.event_name == 'push' && steps.check-app.outputs.app_exists == 'true')
203201
uses: ./.github/actions/build-docker-image
204202
with:
205203
app_name: ${{ env.APP_NAME }}
@@ -212,7 +210,7 @@ jobs:
212210
(github.event_name == 'issue_comment' &&
213211
github.event.issue.pull_request &&
214212
github.event.comment.body == '/deploy-review-app') ||
215-
(steps.get-pr.outputs.has_pr == 'true' && steps.check-app.outputs.app_exists == 'true')
213+
(github.event_name == 'push' && steps.check-app.outputs.app_exists == 'true')
216214
uses: actions/github-script@v7
217215
with:
218216
script: |
@@ -238,7 +236,7 @@ jobs:
238236
(github.event_name == 'issue_comment' &&
239237
github.event.issue.pull_request &&
240238
github.event.comment.body == '/deploy-review-app') ||
241-
(steps.get-pr.outputs.has_pr == 'true' && steps.check-app.outputs.app_exists == 'true')
239+
(github.event_name == 'push' && steps.check-app.outputs.app_exists == 'true')
242240
id: deploy
243241
uses: ./.github/actions/deploy-to-control-plane
244242
with:

0 commit comments

Comments
 (0)