feat: 엔티티를 제거할 때, 해당 엔티티에 단일 종속적인 엔티티들을 제거한다 (#76) #129
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
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle | |
name: Java CI/CD With Gradle | |
on: | |
push: | |
branches: ["main", "dev"] | |
pull_request: | |
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' | |
## 1) 테스트용 application.yml 파일 생성하기 | |
- name: Make test application.yml | |
run: | | |
cd ./src/main/resources | |
touch ./application.yml | |
echo "${{ secrets.TEST_APPLICATION }}" > ./application.yml | |
shell: bash | |
## 2) 스프링 프로젝트 jar 파일 빌드 | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Test with Gradle | |
run: ./gradlew test | |
## 3) 배포용 application.yml 파일 생성 | |
- name: Make prod application.yml | |
run: echo "${{ secrets.PROD_APPLICATION }}" > ./application.yml | |
shell: bash | |
- name: Build with Gradle | |
run: ./gradlew build | |
## 4) jar 파일 생성 | |
- name: Make jar | |
run: ./gradlew bootJar | |
- name: Set up Docker buildx | |
uses: docker/setup-buildx-action@v2 | |
## 5) Docker Hub에 이미지 push | |
- name: Docker build and push | |
run: | | |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
docker buildx build --platform linux/amd64,linux/arm64 --tag ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_API_REPO }}:${{ secrets.DOCKER_TAG }} --push --file Dockerfile . | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
name: deploy | |
steps: | |
## 6) ec2에서 docker compose up | |
- name: EC2 docker compose up | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.AWS_SSH_HOST }} | |
username: ${{ secrets.AWS_SSH_USERNAME }} | |
key: ${{ secrets.AWS_SSH_KEY }} | |
port: ${{ secrets.AWS_SSH_PORT }} | |
script: | | |
sudo docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
if [ "$(docker ps -aq -f name=${{ secrets.CONTAINER_NAME }})" ]; then | |
docker stop ${{ secrets.CONTAINER_NAME }} | |
docker rm ${{ secrets.CONTAINER_NAME }} | |
fi | |
sudo docker compose up -d |