1+ name : GOGO Betting On-premise stage CD Workflow
2+
3+ on :
4+ push :
5+ branches :
6+ - ' develop'
7+ workflow_dispatch :
8+
9+ jobs :
10+ CI :
11+ runs-on : ubuntu-latest
12+
13+ steps :
14+ - name : Checkout code
15+ uses : actions/checkout@v3
16+
17+ - name : Set up JDK 17
18+ uses : actions/setup-java@v3
19+ with :
20+ java-version : ' 17'
21+ distribution : ' temurin'
22+ cache : gradle
23+
24+ - name : Setup Gradle
25+ uses : gradle/gradle-build-action@v2
26+
27+ - name : Setup Gradle's permission
28+ run : chmod +x gradlew
29+
30+ - name : Build with Gradle
31+ run : ./gradlew clean build
32+
33+ deploy :
34+ needs : CI
35+ runs-on : ubuntu-latest
36+ steps :
37+ - name : Checkout code
38+ uses : actions/checkout@v3
39+
40+ - name : Install sshpass and OpenSSH
41+ run : |
42+ sudo apt-get update && sudo apt-get install -y sshpass openssh-client
43+
44+ - name : Create SSH key for Bastion and Target
45+ run : |
46+ echo "${{ secrets.STAGE_BASTION_SSH_KEY }}" > $HOME/bastion_key.pem
47+ chmod 600 $HOME/bastion_key.pem
48+
49+ - name : SSH Command to Deploy using Bastion and Target Instance
50+ run : |
51+ ssh -i "$HOME/bastion_key.pem" -o StrictHostKeyChecking=no ubuntu@${{ secrets.STAGE_ON_PREMISE_HOST }} << 'EOF'
52+ mkdir -p /home/ubuntu/gogo-betting
53+ cd /home/ubuntu/gogo-betting
54+
55+ if [ ! -d ".git" ]; then
56+ git clone -b develop https://github.com/team-gogo/gogo-betting.git .
57+ else
58+ git pull origin develop
59+ fi
60+
61+ ./gradlew clean build
62+
63+ docker build -f DockerFileStage -t gogo-betting-stage .
64+
65+ docker stop gogo-betting-stage || true
66+ docker rm gogo-betting-stage || true
67+
68+ docker run -d -p 8083:8083 --add-host host.docker.internal:host-gateway --name gogo-betting-stage gogo-betting-stage
69+
70+ - name : SSH Success Notification
71+ if : success()
72+ uses : sarisia/actions-status-discord@v1
73+ with :
74+ webhook : ${{ secrets.DISCORD_WEBHOOK }}
75+ color : 0x4CAF50
76+ title : " 배포 성공"
77+ message : " GOGO User On-premise stage deployment completed successfully."
78+
79+ - name : SSH Failure Notification
80+ if : failure()
81+ uses : sarisia/actions-status-discord@v1
82+ with :
83+ webhook : ${{ secrets.DISCORD_WEBHOOK }}
84+ color : 0xFF4C4C
85+ title : " 배포 실패"
86+ message : " GOGO User On-premise stage deployment failed. Check the logs for details."
0 commit comments