Skip to content

Commit a8ecd2a

Browse files
committed
fix: GitHub Actions오류로 인한 deploy.yml 수정
1 parent 36e793e commit a8ecd2a

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

.github/workflows/deploy.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,39 @@ on:
66
- main # main 브랜치 push 시 자동 배포
77

88
jobs:
9-
deploy:
10-
name: Deploy to EC2 Server
9+
build-and-deploy:
10+
name: Build and Deploy to EC2 Server
1111
runs-on: ubuntu-latest
1212

1313
steps:
1414
- name: Checkout code
1515
uses: actions/checkout@v4
1616

17+
- name: Set up JDK 17
18+
uses: actions/setup-java@v4
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 build -x test
28+
1729
- name: Set up SSH key
1830
run: |
1931
mkdir -p ~/.ssh
2032
echo "${{ secrets.EC2_KEY }}" > ~/.ssh/id_rsa
2133
chmod 600 ~/.ssh/id_rsa
2234
ssh-keyscan -H ${{ secrets.EC2_HOST }} >> ~/.ssh/known_hosts
2335
24-
- name: SSH and deploy
36+
- name: Securely copy JAR file to EC2
37+
run: |
38+
scp -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no \
39+
./build/libs/Debug_Visual-0.0.1-SNAPSHOT.jar \
40+
${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }}:"/home/ec2-user/Zivorp Backend/Debug_Visual-0.0.1-SNAPSHOT.jar"
41+
42+
- name: SSH and run deploy script
2543
run: |
26-
ssh ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} "cd ~ && ./deploy.sh"
44+
ssh ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} "cd ~ && ./deploy.sh"

0 commit comments

Comments
 (0)