refactor: DTO to Record Type #20
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI / CD | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
# Spring Boot 애플리케이션을 빌드하여 도커허브에 푸시 | |
application-build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
# 지정한 저장소(현재 REPO)에서 코드를 워크플로우 환경으로 가져오도록 하는 github action | |
steps: | |
- uses: actions/checkout@v4 | |
# 1. Java 17 세팅 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
# 2. application-private.yml 설정 | |
- name: Set application-private.yml file | |
run: | | |
# application-private.yml 파일 생성 | |
cd ./src/main/resources | |
touch ./application-private.yml | |
# GitHub-Actions 에서 설정한 값을 application-private.yml 파일에 쓰기 | |
echo "${{ secrets.APPLICATION_PRIVATE_YML }}" >> ./application-private.yml | |
shell: bash | |
# 3. gradle을 통해 소스를 빌드. | |
- name: Build with Gradle | |
run: | | |
chmod +x ./gradlew | |
./gradlew clean build | |
# 4. Docker image 업로드 | |
# { username/repository } 로 빌드 & . 이 의미하는 것은 Dockerfile의 경로를 의미함. | |
- name: Docker build & push to docker repo | |
run: | | |
docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }} | |
docker build -t ${{ secrets.DOCKER_USER }}/wssrs . | |
docker push ${{ secrets.DOCKER_USER }}/wssrs | |
run-docker-image-on-ec2: | |
needs: application-build | |
runs-on: self-hosted | |
steps: | |
- name: docker pull | |
run: sudo docker pull ${{ secrets.DOCKER_USER }}/wssrs:latest | |
- name: docker stop container | |
run: sudo docker stop clerker:latest || true | |
- name: docker run new container | |
run: sudo docker run --name github-actions-demo --rm -d -p 8080:8080 ${{ secrets.DOCKER_USER }}/wssrs:latest | |
- name: delete old docker image | |
run: sudo docker image prune -f |