File tree Expand file tree Collapse file tree 1 file changed +14
-7
lines changed
Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change 11name : Continuous Deployment
22
33on :
4- # 1️⃣ Automatically trigger after CI passes (only for main)
54 workflow_run :
65 workflows : ["Continuous Integration"]
76 types :
87 - completed
98 branches :
109 - main
1110
12- # 2️⃣ Fallback: trigger on push (for non-main or if CI doesn’t exist)
1311 push :
1412 branches :
1513 - main
16- - feature/** # optional — allow testing on feature branches
17- # - dev # optional — allow dev environment deploys
14+ - feature/** # allow testing
15+ - dev
1816
19- # 3️⃣ Manual trigger anytime
2017 workflow_dispatch :
2118
2219jobs :
2320 deploy :
24- # Only run auto-deploy if CI passed OR triggered manually/push
2521 if : >
2622 github.event_name == 'workflow_dispatch' ||
2723 github.event_name == 'push' ||
3430 - name : Checkout code
3531 uses : actions/checkout@v4
3632
33+ - name : Determine branch name
34+ id : vars
35+ run : |
36+ echo "branch_name=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
37+
38+ - name : Log branch being deployed
39+ run : echo "🚀 Deploying branch: ${{ steps.vars.outputs.branch_name }}"
40+
3741 - name : Test SSH connection to EC2
38423943 with :
5054 key : ${{ secrets.EC2_SSH_KEY }}
5155 script : |
5256 cd /home/ubuntu/sentiment-mlops
53- git pull origin main
57+ echo "Fetching latest code..."
58+ git fetch origin
59+ git checkout ${{ steps.vars.outputs.branch_name }} || git checkout -b ${{ steps.vars.outputs.branch_name }}
60+ git pull origin ${{ steps.vars.outputs.branch_name }}
5461 chmod +x ./deploy.sh
5562 ./deploy.sh
You can’t perform that action at this time.
0 commit comments