@@ -7,9 +7,7 @@ run-name: Deploy Control Plane Staging App
77on :
88 push :
99 branches :
10- - ' main'
11- - ' master'
12- - ${{ github.vars.STAGING_APP_BRANCH }}
10+ - ' *'
1311 workflow_dispatch :
1412
1513# Convert the GitHub secret variables to environment variables for use by the Control Plane CLI
@@ -31,23 +29,29 @@ jobs:
3129
3230 validate-branch :
3331 runs-on : ubuntu-latest
32+ outputs :
33+ is_deployable : ${{ steps.check_branch.outputs.is_deployable }}
3434 steps :
3535 - name : Check if allowed branch
36+ id : check_branch
3637 run : |
3738 if [[ -n "${STAGING_APP_BRANCH}" ]]; then
38- if [[ "${GITHUB_REF#refs/heads/}" != "${STAGING_APP_BRANCH}" ]]; then
39- echo "This workflow only runs on configured branch: ${STAGING_APP_BRANCH}"
40- echo "Current branch: ${GITHUB_REF#refs/heads/}"
41- exit 1
39+ if [[ "${GITHUB_REF#refs/heads/}" == "${STAGING_APP_BRANCH}" ]]; then
40+ echo "is_deployable=true" >> $GITHUB_OUTPUT
41+ else
42+ echo "Branch '${GITHUB_REF#refs/heads/}' is not the configured deployment branch '${STAGING_APP_BRANCH}'"
43+ echo "is_deployable=false" >> $GITHUB_OUTPUT
4244 fi
43- elif [[ "${GITHUB_REF}" != "refs/heads/main" && "${GITHUB_REF}" != "refs/heads/master" ]]; then
44- echo "This workflow only runs on main or master branch (no STAGING_APP_BRANCH configured)"
45- echo "Current branch: ${GITHUB_REF#refs/heads/}"
46- exit 1
45+ elif [[ "${GITHUB_REF}" == "refs/heads/main" || "${GITHUB_REF}" == "refs/heads/master" ]]; then
46+ echo "is_deployable=true" >> $GITHUB_OUTPUT
47+ else
48+ echo "Branch '${GITHUB_REF#refs/heads/}' is not main/master (no STAGING_APP_BRANCH configured)"
49+ echo "is_deployable=false" >> $GITHUB_OUTPUT
4750 fi
4851
4952 build :
5053 needs : validate-branch
54+ if : needs.validate-branch.outputs.is_deployable == 'true'
5155 runs-on : ubuntu-latest
5256 outputs :
5357 image_tag : ${{ steps.build.outputs.image_tag }}
0 commit comments