@@ -43,32 +43,30 @@ jobs:
43
43
- name : Setup Environment
44
44
uses : ./.github/actions/setup-environment
45
45
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'
51
52
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
58
56
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
61
63
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 }}
68
66
69
67
- name : Check if Review App Exists
70
68
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 '
72
70
env :
73
71
CPLN_TOKEN : ${{ secrets.CPLN_TOKEN }}
74
72
run : |
84
82
(github.event_name == 'issue_comment' &&
85
83
github.event.issue.pull_request &&
86
84
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')
88
86
run : |
89
87
PR_DATA=$(gh pr view ${{ env.PR_NUMBER }} --repo ${{ github.repository }} --json headRefName,headRefOid)
90
88
echo "PR_REF=$(echo "$PR_DATA" | jq -r '.headRefName')" >> $GITHUB_OUTPUT
97
95
(github.event_name == 'issue_comment' &&
98
96
github.event.issue.pull_request &&
99
97
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')
101
99
id : create-comment
102
100
uses : actions/github-script@v7
103
101
with :
@@ -116,15 +114,15 @@ jobs:
116
114
(github.event_name == 'issue_comment' &&
117
115
github.event.issue.pull_request &&
118
116
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')
120
118
run : echo "COMMENT_ID=${{ fromJSON(steps.create-comment.outputs.result).commentId }}" >> $GITHUB_ENV
121
119
122
120
- name : Set Workflow URL
123
121
if : |
124
122
(github.event_name == 'issue_comment' &&
125
123
github.event.issue.pull_request &&
126
124
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')
128
126
id : workflow-url
129
127
uses : actions/github-script@v7
130
128
with :
@@ -154,7 +152,7 @@ jobs:
154
152
(github.event_name == 'issue_comment' &&
155
153
github.event.issue.pull_request &&
156
154
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')
158
156
uses : actions/github-script@v7
159
157
with :
160
158
script : |
@@ -167,7 +165,7 @@ jobs:
167
165
(github.event_name == 'issue_comment' &&
168
166
github.event.issue.pull_request &&
169
167
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')
171
169
uses : actions/github-script@v7
172
170
with :
173
171
script : |
@@ -191,15 +189,15 @@ jobs:
191
189
(github.event_name == 'issue_comment' &&
192
190
github.event.issue.pull_request &&
193
191
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')
195
193
run : git checkout ${{ steps.getRef.outputs.PR_REF }}
196
194
197
195
- name : Build Docker Image
198
196
if : |
199
197
(github.event_name == 'issue_comment' &&
200
198
github.event.issue.pull_request &&
201
199
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')
203
201
uses : ./.github/actions/build-docker-image
204
202
with :
205
203
app_name : ${{ env.APP_NAME }}
@@ -212,7 +210,7 @@ jobs:
212
210
(github.event_name == 'issue_comment' &&
213
211
github.event.issue.pull_request &&
214
212
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')
216
214
uses : actions/github-script@v7
217
215
with :
218
216
script : |
@@ -238,7 +236,7 @@ jobs:
238
236
(github.event_name == 'issue_comment' &&
239
237
github.event.issue.pull_request &&
240
238
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')
242
240
id : deploy
243
241
uses : ./.github/actions/deploy-to-control-plane
244
242
with :
0 commit comments