55 branches :
66 - main
77 - develop
8+ pull_request :
9+ types : [closed]
10+ branches :
11+ - main
12+ - develop
813 workflow_dispatch :
914 inputs :
1015 environment :
2530 backend :
2631 name : Deploy Backend
2732 runs-on : ubuntu-latest
33+ # Only run this job when a PR is merged (not when closed without merging)
34+ if : github.event_name != 'pull_request' || github.event.pull_request.merged == true
2835
2936 steps :
3037 - uses : actions/checkout@v3
6067 if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
6168 echo "VAPOR_ENV=${{ github.event.inputs.environment }}" >> "$GITHUB_ENV"
6269 echo "TEST_MODE=${{ github.event.inputs.test_mode }}" >> "$GITHUB_ENV"
63- elif [[ "${{ github.ref_name }}" == "develop" ]]; then
70+ elif [[ "${{ github.base_ref }}" == "develop" || "${{ github. ref_name }}" == "develop" ]]; then
6471 echo "VAPOR_ENV=staging" >> "$GITHUB_ENV"
6572 echo "TEST_MODE=false" >> "$GITHUB_ENV"
6673 else
7077
7178 - name : Log Branch and Environment
7279 run : |
73- echo "🚀 Deploying branch ${{ github.ref_name }} to Vapor environment: ${{ env.VAPOR_ENV }}"
80+ echo "🚀 Deploying to Vapor environment: ${{ env.VAPOR_ENV }}"
7481 echo "🧪 Test mode: ${{ env.TEST_MODE }}"
7582
7683 - name : Validate Deployment Configuration
9299 name : Deploy Frontend
93100 runs-on : ubuntu-latest
94101 needs : backend
102+ # Only run this job when a PR is merged (not when closed without merging)
103+ if : github.event_name != 'pull_request' || github.event.pull_request.merged == true
95104
96105 steps :
97106 - uses : actions/checkout@v3
@@ -105,7 +114,7 @@ jobs:
105114 echo "DO_APP_ID=${{ secrets.DIGITALOCEAN_PRODUCTION_APP_ID }}" >> "$GITHUB_ENV"
106115 fi
107116 echo "TEST_MODE=${{ github.event.inputs.test_mode }}" >> "$GITHUB_ENV"
108- elif [[ "${{ github.ref_name }}" == "develop" ]]; then
117+ elif [[ "${{ github.base_ref }}" == "develop" || "${{ github. ref_name }}" == "develop" ]]; then
109118 echo "DO_APP_ID=${{ secrets.DIGITALOCEAN_STAGING_APP_ID }}" >> "$GITHUB_ENV"
110119 echo "TEST_MODE=false" >> "$GITHUB_ENV"
111120 else
0 commit comments