Skip to content

feat: ci/cd 구축

feat: ci/cd 구축 #1

Workflow file for this run

name: Java CD with Gradle
on:
push:
branches: [ "main" ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Connect to EC2 via SSH
uses: appleboy/ssh-action@master
env:
APPLICATION_YML: ${{ secrets.APPLICATION_YML }}
APPLICATION_TEST_YML: ${{ secrets.APPLICATION_TEST_YML }}
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }}
script_stop: true
envs: APPLICATION_YML, APPLICATION_TEST_YML
# git clone 같은 초기 작업은 ec2에서 먼저 진행
script: |
cd /home/server/purelabel/PureLabel
git switch dev
git pull origin dev
rm -rf src/main/resources/application.yml
mkdir -p src/main/resources
echo "$APPLICATION_YML" > src/main/resources/application.yml
rm -rf src/test/resources/application.yml
mkdir -p src/test/resources
echo "$APPLICATION_TEST_YML" > src/test/resources/application.yml
chmod +x gradlew
./gradlew clean
./gradlew build
sudo fuser -k -n tcp "${{ secrets.SERVER_PORT }}" || true
nohup java -jar build/libs/*SNAPSHOT.jar > ./output.log 2>&1 &