Skip to content

fix: init

fix: init #3

Workflow file for this run

name: CD with Gradle
on:
push:
branches: [ "main" ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: "temurin"
- name: Make application.yml
run: |
cd ./src/main/resources
touch ./application.yml
echo "${{ secrets.APPLICATION }}" > ./application.yml
shell: bash
- name: Build with Gradle
run: |
chmod +x ./gradlew
./gradlew clean build -x test
- name: Docker build
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -t sopo_v2 . # Dockerfile 경로 수정
docker tag sopo_v2 ${{ secrets.DOCKER_USERNAME }}/sopo_v2:latest
docker push ${{ secrets.DOCKER_USERNAME }}/sopo_v2:latest
- name: Deploy with SSH
if: github.ref == 'refs/heads/main'
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }} # EC2 인스턴스 퍼블릭 DNS
username: ubuntu
key: ${{ secrets.PRIVATE_KEY }} # pem 키
# 도커 작업
script: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker stop sopo_v2
docker rm sopo_v2
docker network disconnect redis-network sopo_v2
docker rmi ${{ secrets.DOCKER_USERNAME }}/sopo_v2:latest
docker pull ${{ secrets.DOCKER_USERNAME }}/sopo_v2:latest
docker run -d -p 80:8080 --name sopo_v2 ${{ secrets.DOCKER_USERNAME }}/sopo_v2:latest
docker network connect redis-network sopo_v2