@@ -48,11 +48,11 @@ jobs:
48
48
49
49
- name : Verify Environment Variables
50
50
run : |
51
- # Required secrets
51
+ # Required actions secrets
52
52
: "${GITHUB_TOKEN:?Required secret GITHUB_TOKEN not set}"
53
53
: "${CPLN_TOKEN:?Required secret CPLN_TOKEN_STAGING not set}"
54
54
55
- # Required variables
55
+ # Required actions variables
56
56
: "${CPLN_ORG:?Required variable CPLN_ORG_STAGING not set}"
57
57
: "${STAGING_APP_NAME:?Required variable STAGING_APP_NAME not set}"
58
58
: "${REVIEW_APP_PREFIX:?Required variable REVIEW_APP_PREFIX not set}"
@@ -104,8 +104,12 @@ jobs:
104
104
echo "SHOULD_DEPLOY=true" >> $GITHUB_OUTPUT
105
105
setup_pr_deployment "${{ github.event.issue.number }}"
106
106
elif [[ "${{ github.event_name }}" == "push" ]]; then
107
- PR_NUMBER=$(gh pr list --head ${{ github.ref_name }} --json number --jq '.[0].number')
107
+ # Get PR number for the current branch, handling refs/heads/ prefix
108
+ BRANCH_NAME="${{ github.ref_name }}"
109
+ PR_NUMBER=$(gh pr list --head "$BRANCH_NAME" --json number,state --jq '.[] | select(.state=="OPEN") | .number')
110
+
108
111
if [ -n "$PR_NUMBER" ]; then
112
+ echo "Found PR #$PR_NUMBER for branch $BRANCH_NAME"
109
113
APP_NAME="${{ env.REVIEW_APP_PREFIX }}-pr-$PR_NUMBER"
110
114
if check_app_exists "$APP_NAME"; then
111
115
echo "SHOULD_DEPLOY=true" >> $GITHUB_OUTPUT
@@ -114,6 +118,7 @@ jobs:
114
118
no_deployment "No existing review app found for PR $PR_NUMBER"
115
119
fi
116
120
else
121
+ echo "No open PR found for branch $BRANCH_NAME"
117
122
no_deployment "No PR found for this branch"
118
123
fi
119
124
else
@@ -156,7 +161,7 @@ jobs:
156
161
}
157
162
158
163
- name : Create Initial Comment
159
- if : env.IS_STAGING != 'true'
164
+ if : env.IS_STAGING != 'true' && env.PR_NUMBER != ''
160
165
id : create-comment
161
166
uses : actions/github-script@v7
162
167
with :
0 commit comments