Skip to content

feat: 현재 순위 조회 기능 추가 #12

feat: 현재 순위 조회 기능 추가

feat: 현재 순위 조회 기능 추가 #12

name: Deploy to EC2
on:
push:
branches: [ main ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'
- name: Build with Gradle
run: |
chmod +x ./gradlew
./gradlew build -x test
env:
DB_HOST: ${{ secrets.DB_HOST }}
DB_USERNAME: ${{ secrets.DB_USERNAME }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
- name: Deploy to EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ubuntu
key: ${{ secrets.EC2_SSH_KEY }}
script: |
sudo tee /etc/systemd/system/spring-app.service << EOF
[Unit]
Description=Spring Boot Application
After=network.target
[Service]
Type=simple
User=ubuntu
WorkingDirectory=/home/ubuntu/app
Environment="DB_HOST=${{ secrets.DB_HOST }}"
Environment="DB_USERNAME=${{ secrets.DB_USERNAME }}"
Environment="DB_PASSWORD=${{ secrets.DB_PASSWORD }}"
ExecStart=/usr/bin/java -jar hidden_treasure-0.0.1-SNAPSHOT.jar
Restart=always
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl restart spring-app
- name: Copy JAR
uses: appleboy/scp-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ubuntu
key: ${{ secrets.EC2_SSH_KEY }}
source: "build/libs/*.jar"
target: "/home/ubuntu/app"
strip_components: 2
- name: Restart Spring Boot App
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ubuntu
key: ${{ secrets.EC2_SSH_KEY }}
script: |
sudo systemctl restart spring-app