Skip to content

Commit 777212b

Browse files
committed
[FEAT] CI/CD 파일 수정
1 parent 705b9e9 commit 777212b

2 files changed

Lines changed: 51 additions & 110 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Deploy Backend to EC2
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
jobs:
10+
build-and-deploy:
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+
23+
- name: Grant execute permission for gradlew
24+
run: chmod +x gradlew
25+
26+
- name: Build with Gradle
27+
run: ./gradlew clean build -x test
28+
29+
- name: Create SSH key file
30+
run: |
31+
echo "${{ secrets.EC2_SSH_KEY }}" > private_key.pem
32+
chmod 600 private_key.pem
33+
34+
- name: Deploy to EC2
35+
run: |
36+
scp -i private_key.pem -o StrictHostKeyChecking=no \
37+
build/libs/*.jar ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }}:/home/ubuntu/app.jar
38+
39+
ssh -i private_key.pem -o StrictHostKeyChecking=no \
40+
${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} << 'EOF'
41+
sudo systemctl restart studylink
42+
sudo systemctl status studylink
43+
EOF
44+
45+
- name: Clean up
46+
if: always()
47+
run: rm -f private_key.pem
48+
49+
- name: Send deployment notification
50+
if: success()
51+
run: echo "Deployment successful!"

.github/workflows/gradle.yml

Lines changed: 0 additions & 110 deletions
This file was deleted.

0 commit comments

Comments
 (0)