refactor: 후원 API 중복 요청을 방지한다. (따닥 방지) (#448) #200
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: cd-dev-docker | |
on: | |
push: | |
branches: [ "dev" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
token: ${{secrets.ACTION_TOKEN}} | |
submodules: true | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Make directory for deliver | |
run: mkdir deploy | |
- name: Build with Gradle | |
run: ./gradlew clean build | |
- name: Copy jar | |
run: cp ./build/libs/*.jar ./deploy/ | |
# 도커 컴포즈 설정 파일 서버로 전달하기(복사 후 붙여넣기) | |
- name: Send docker-compose.yml | |
uses: appleboy/scp-action@master | |
with: | |
username: ec2-user | |
host: ${{ secrets.AWS_DEV_HOSTNAME }} | |
key: ${{ secrets.AWS_DEV_PRIVATE_KEY }} | |
source: "./src/main/resources/backend-config/docker-compose.yml" | |
target: "/home/ec2-user/" | |
# nginx 설정 파일 서버로 전달하기(복사 후 붙여넣기) | |
- name: Send nginx.conf | |
uses: appleboy/scp-action@master | |
with: | |
username: ec2-user | |
host: ${{ secrets.AWS_DEV_HOSTNAME }} | |
key: ${{ secrets.AWS_DEV_PRIVATE_KEY }} | |
source: "./nginx/nginx.conf" | |
target: "/home/ec2-user/" | |
## springboot 도커 이미지 빌드 후 도커허브에 push하기 | |
- name: web springboot docker build and push | |
run: | | |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
docker build -t ${{ secrets.DOCKER_REPOSITORY }}:backend . | |
docker push ${{ secrets.DOCKER_REPOSITORY }}:backend | |
## nginx 도커 이미지 빌드 후 도커허브에 push하기 | |
- name: web nginx docker build and push | |
run: | | |
cd ./nginx | |
docker build -t ${{ secrets.DOCKER_REPOSITORY }}:nginx . | |
docker push ${{ secrets.DOCKER_REPOSITORY }}:nginx | |
# nginx.conf 경로 변경 후 도커 컴포즈 실행하기 | |
# 도커 허브에서 jar파일 및 pull후에 컴포즈 up | |
- name: Deploy to Dev | |
uses: appleboy/ssh-action@master | |
with: | |
username: ec2-user | |
host: ${{ secrets.AWS_DEV_HOSTNAME }} | |
key: ${{ secrets.AWS_DEV_PRIVATE_KEY }} | |
script: | | |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }} | |
cd src/main/resources/backend-config | |
sudo cp /home/ec2-user/nginx/nginx.conf /home/ec2-user/src/main/resources/backend-config/nginx/nginx.conf | |
docker-compose down | |
docker rmi $(docker images -q) | |
docker-compose up --build -d |