11name : Deploy Review App to Control Plane
22
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) }}
44
55on :
66 issue_comment :
2727 (github.event_name == 'issue_comment' &&
2828 github.event.issue.pull_request &&
2929 github.event.comment.body == '/deploy-review-app') ||
30- (github.event_name == 'push' &&
31- github.event.pull_request)
30+ github.event_name == 'push'
3231 runs-on : ubuntu-latest
3332 permissions :
3433 contents : read
5554 if [ -n "$PR_NUMBER" ]; then
5655 echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
5756 echo "APP_NAME=qa-react-webpack-rails-tutorial-pr-$PR_NUMBER" >> $GITHUB_ENV
57+ echo "has_pr=true" >> $GITHUB_OUTPUT
5858 else
5959 echo "No PR found for this branch"
6060 exit 0
6868
6969 - name : Check if Review App Exists
7070 id : check-app
71- if : github.event_name == 'push'
71+ if : github.event_name == 'push' && steps.get-pr.outputs.has_pr == 'true'
7272 env :
7373 CPLN_TOKEN : ${{ secrets.CPLN_TOKEN }}
7474 run : |
8080
8181 - name : Get PR HEAD Ref
8282 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')
8386 run : |
8487 PR_DATA=$(gh pr view ${{ env.PR_NUMBER }} --repo ${{ github.repository }} --json headRefName,headRefOid)
8588 echo "PR_REF=$(echo "$PR_DATA" | jq -r '.headRefName')" >> $GITHUB_OUTPUT
@@ -88,10 +91,15 @@ jobs:
8891 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
8992
9093 - 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')
9197 run : git checkout ${{ steps.getRef.outputs.PR_REF }}
9298
9399 - 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')
95103 uses : ./.github/actions/deploy-to-control-plane
96104 with :
97105 app_name : ${{ env.APP_NAME }}
0 commit comments