11name : Deploy to Control Plane
22
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) }}
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) }}
44
55on :
66 issue_comment :
1515
1616# Use concurrency to cancel in-progress runs
1717concurrency :
18- group : ${{ github.ref == '${{ steps.default-branch.outputs.name }} ' && 'deploy-staging' || format('deploy-pr-{0}', github.event.issue.number) }}
18+ group : ${{ github.ref == 'main ' && 'deploy-staging' || format('deploy-pr-{0}', github.event.issue.number) }}
1919 cancel-in-progress : true
2020
2121jobs :
@@ -36,11 +36,10 @@ jobs:
3636 issues : write
3737 env :
3838 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
39- CPLN_ORG : ${{ secrets.CPLN_ORG_STAGING }}
4039 CPLN_TOKEN : ${{ secrets.CPLN_TOKEN_STAGING }}
41- STAGING_APP_NAME : ${{ secrets.STAGING_APP_NAME }}
42- REVIEW_APP_PREFIX : ${{ secrets.REVIEW_APP_PREFIX }}
43- CPLN_APP_NAME : ${{ secrets.CPLN_APP_NAME || github.event.repository.name }}
40+ CPLN_ORG : ${{ secrets.CPLN_ORG_STAGING }}
41+ STAGING_APP_NAME : ${{ vars.STAGING_APP_NAME }}
42+ REVIEW_APP_PREFIX : ${{ vars.REVIEW_APP_PREFIX }}
4443
4544 steps :
4645 - uses : actions/checkout@v4
5756
5857 echo "All required environment variables are set"
5958
59+ - name : Set Default Branch
60+ id : default-branch
61+ run : |
62+ DEFAULT_BRANCH="main"
63+ echo "DEFAULT_BRANCH=$DEFAULT_BRANCH" >> $GITHUB_ENV
64+
6065 - name : Setup Deployment Configuration
6166 id : setup
6267 run : |
8792 exit 0
8893 }
8994
90- # Get default branch
91- DEFAULT_BRANCH="refs/heads/$(gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name')"
92- echo "DEFAULT_BRANCH=$DEFAULT_BRANCH" >> $GITHUB_OUTPUT
93-
9495 # Check if we should deploy
95- if [[ "${{ github.ref }}" == "$DEFAULT_BRANCH" ]]; then
96+ if [[ "${{ github.ref }}" == "${{ env. DEFAULT_BRANCH }} " ]]; then
9697 echo "SHOULD_DEPLOY=true" >> $GITHUB_OUTPUT
9798 echo "IS_STAGING=true" >> $GITHUB_ENV
9899 echo "APP_NAME=${{ env.STAGING_APP_NAME }}" >> $GITHUB_ENV
0 commit comments