1
1
name : Deploy to Control Plane
2
2
3
- run-name : ${{ github.event_name == 'issue_comment' && format('Deploying Review App for {0}', github.ref_name) || github.ref == 'main ' && 'Deploying to Staging' || format('Deploying Review App for {0}', github.ref_name) }}
3
+ run-name : ${{ github.event_name == 'issue_comment' && format('Deploying Review App for {0}', github.ref_name) || github.ref == '${{ steps.default-branch.outputs.name }} ' && 'Deploying to Staging' || format('Deploying Review App for {0}', github.ref_name) }}
4
4
5
5
on :
6
6
issue_comment :
15
15
16
16
# Use concurrency to cancel in-progress runs
17
17
concurrency :
18
- group : ${{ github.ref == 'main ' && 'deploy-staging' || format('deploy-pr-{0}', github.event.issue.number) }}
18
+ group : ${{ github.ref == '${{ steps.default-branch.outputs.name }} ' && 'deploy-staging' || format('deploy-pr-{0}', github.event.issue.number) }}
19
19
cancel-in-progress : true
20
20
21
21
jobs :
37
37
env :
38
38
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
39
39
CPLN_TOKEN : ${{ secrets.CPLN_TOKEN_STAGING }}
40
- CPLN_ORG : ${{ secrets .CPLN_ORG_STAGING }}
40
+ CPLN_ORG : ${{ vars .CPLN_ORG_STAGING }}
41
41
STAGING_APP_NAME : ${{ vars.STAGING_APP_NAME }}
42
42
REVIEW_APP_PREFIX : ${{ vars.REVIEW_APP_PREFIX }}
43
43
@@ -48,19 +48,16 @@ jobs:
48
48
49
49
- name : Verify Environment Variables
50
50
run : |
51
- # Required environment variables
52
- : "${CPLN_ORG:?Required environment variable not set}"
53
- : "${CPLN_TOKEN:?Required environment variable not set}"
54
- : "${REVIEW_APP_PREFIX:?Required environment variable not set}"
55
- : "${STAGING_APP_NAME:?Required environment variable not set}"
51
+ # Required secrets
52
+ : "${GITHUB_TOKEN:?Required secret GITHUB_TOKEN not set}"
53
+ : "${CPLN_TOKEN:?Required secret CPLN_TOKEN_STAGING not set}"
56
54
57
- echo "All required environment variables are set"
58
-
59
- - name : Set Default Branch
60
- id : default-branch
61
- run : |
62
- DEFAULT_BRANCH="main"
63
- echo "DEFAULT_BRANCH=$DEFAULT_BRANCH" >> $GITHUB_ENV
55
+ # Required variables
56
+ : "${CPLN_ORG:?Required variable CPLN_ORG_STAGING not set}"
57
+ : "${STAGING_APP_NAME:?Required variable STAGING_APP_NAME not set}"
58
+ : "${REVIEW_APP_PREFIX:?Required variable REVIEW_APP_PREFIX not set}"
59
+
60
+ echo "All required secrets and variables are set"
64
61
65
62
- name : Setup Deployment Configuration
66
63
id : setup
92
89
exit 0
93
90
}
94
91
92
+ # Get default branch
93
+ DEFAULT_BRANCH="refs/heads/$(gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name')"
94
+ echo "DEFAULT_BRANCH=$DEFAULT_BRANCH" >> $GITHUB_OUTPUT
95
+
95
96
# Check if we should deploy
96
- if [[ "${{ github.ref }}" == "${{ env. DEFAULT_BRANCH }} " ]]; then
97
+ if [[ "${{ github.ref }}" == "$DEFAULT_BRANCH" ]]; then
97
98
echo "SHOULD_DEPLOY=true" >> $GITHUB_OUTPUT
98
99
echo "IS_STAGING=true" >> $GITHUB_ENV
99
100
echo "APP_NAME=${{ env.STAGING_APP_NAME }}" >> $GITHUB_ENV
0 commit comments