File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Deploy to EC2
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+
8+ jobs :
9+ build-and-deploy :
10+ runs-on : ubuntu-latest
11+
12+ steps :
13+ # 1. ์์ค ์ฝ๋ ์ฒดํฌ์์
14+ - name : Checkout
15+ uses : actions/checkout@v3
16+
17+ # 2. JDK 17 ์ค์น
18+ - name : Set up JDK 17
19+ uses : actions/setup-java@v3
20+ with :
21+ java-version : ' 17'
22+ distribution : ' temurin'
23+
24+ # 3. Gradle ์คํ ๊ถํ ๋ถ์ฌ
25+ - name : Grant execute permission for gradlew
26+ run : chmod +x ./gradlew
27+
28+ # 4. Gradle๋ก ํ๋ก์ ํธ ๋น๋
29+ - name : Build with Gradle
30+ run : ./gradlew build
31+
32+ # 5. ๋น๋๋ Jar ํ์ผ๊ณผ ํ๊ฒฝ๋ณ์ ํ์ผ์ EC2๋ก ์ ์ก
33+ - name : Deploy to EC2
34+ uses : appleboy/scp-action@master
35+ with :
36+ host : ${{ secrets.AWS_EC2_HOST }}
37+ username : ${{ secrets.AWS_EC2_USERNAME }}
38+ key : ${{ secrets.AWS_SSH_PRIVATE_KEY }}
39+ source : " ./build/libs/*.jar,./deploy.sh"
40+ target : " /home/${{ secrets.AWS_EC2_USERNAME }}/"
41+
42+ # 6. EC2์ ์ ์ํ์ฌ ๋ฐฐํฌ ์คํฌ๋ฆฝํธ ์คํ
43+ - name : Execute deployment script
44+ uses : appleboy/ssh-action@master
45+ with :
46+ host : ${{ secrets.AWS_EC2_HOST }}
47+ username : ${{ secrets.AWS_EC2_USERNAME }}
48+ key : ${{ secrets.AWS_SSH_PRIVATE_KEY }}
49+ script : |
50+ echo "${{ secrets.APPLICATION_ENV }}" > /home/${{ secrets.AWS_EC2_USERNAME }}/matzip.env
51+ chmod +x /home/${{ secrets.AWS_EC2_USERNAME }}/deploy.sh
52+ /home/${{ secrets.AWS_EC2_USERNAME }}/deploy.sh
You canโt perform that action at this time.
0 commit comments