1
1
name : Deploy Review App to Control Plane
2
2
3
- run-name : ${{ github.event_name == 'issue_comment' && 'Deploying Review App' || format('Deploying {0} to Staging App ', github.ref_name) }}
3
+ run-name : ${{ github.event_name == 'issue_comment' && 'Deploying Review App' || format('Updating Review App for {0} ', github.ref_name) }}
4
4
5
5
on :
6
6
issue_comment :
27
27
(github.event_name == 'issue_comment' &&
28
28
github.event.issue.pull_request &&
29
29
github.event.comment.body == '/deploy-review-app') ||
30
- (github.event_name == 'push' &&
31
- github.event.pull_request)
30
+ github.event_name == 'push'
32
31
runs-on : ubuntu-latest
33
32
permissions :
34
33
contents : read
55
54
if [ -n "$PR_NUMBER" ]; then
56
55
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
57
56
echo "APP_NAME=qa-react-webpack-rails-tutorial-pr-$PR_NUMBER" >> $GITHUB_ENV
57
+ echo "has_pr=true" >> $GITHUB_OUTPUT
58
58
else
59
59
echo "No PR found for this branch"
60
60
exit 0
68
68
69
69
- name : Check if Review App Exists
70
70
id : check-app
71
- if : github.event_name == 'push'
71
+ if : github.event_name == 'push' && steps.get-pr.outputs.has_pr == 'true'
72
72
env :
73
73
CPLN_TOKEN : ${{ secrets.CPLN_TOKEN }}
74
74
run : |
80
80
81
81
- name : Get PR HEAD Ref
82
82
id : getRef
83
+ if : |
84
+ github.event_name == 'issue_comment' ||
85
+ (steps.get-pr.outputs.has_pr == 'true' && steps.check-app.outputs.app_exists == 'true')
83
86
run : |
84
87
PR_DATA=$(gh pr view ${{ env.PR_NUMBER }} --repo ${{ github.repository }} --json headRefName,headRefOid)
85
88
echo "PR_REF=$(echo "$PR_DATA" | jq -r '.headRefName')" >> $GITHUB_OUTPUT
@@ -88,10 +91,15 @@ jobs:
88
91
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
89
92
90
93
- name : Checkout PR Branch
94
+ if : |
95
+ github.event_name == 'issue_comment' ||
96
+ (steps.get-pr.outputs.has_pr == 'true' && steps.check-app.outputs.app_exists == 'true')
91
97
run : git checkout ${{ steps.getRef.outputs.PR_REF }}
92
98
93
99
- name : Deploy to Control Plane
94
- if : github.event_name == 'issue_comment' || steps.check-app.outputs.app_exists == 'true'
100
+ if : |
101
+ github.event_name == 'issue_comment' ||
102
+ (steps.get-pr.outputs.has_pr == 'true' && steps.check-app.outputs.app_exists == 'true')
95
103
uses : ./.github/actions/deploy-to-control-plane
96
104
with :
97
105
app_name : ${{ env.APP_NAME }}
0 commit comments