Merge pull request #268 from junseoparkk/feat/lounge-withdraw-event #159
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: 백엔드 DEV CD | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- dev | |
jobs: | |
docker-build-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: 리포지토리 체크아웃 | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
token: ${{ secrets.ACTIONS_TOKEN }} | |
- name: JDK 17 버전 설치 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Gradle 캐싱 | |
uses: actions/cache@v4 | |
id: cache-gradle | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Gradle 을 통해 빌드 | |
run: | | |
chmod +x ./gradlew | |
./gradlew bootJar | |
- name: Docker 빌드 도구 설정 | |
uses: docker/[email protected] | |
- name: Docker Hub 로그인 | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DEV_DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DEV_DOCKER_HUB_ACCESS_TOKEN }} | |
- name: Docker 이미지 빌드 및 푸시 | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ./Dockerfile-dev | |
push: true | |
platforms: linux/amd64 | |
tags: ${{ secrets.DEV_DOCKER_HUB_REPOSITORY }}:${{ secrets.DEV_IMAGE_TAG }} | |
docker-pull-and-run: | |
runs-on: [ self-hosted, Linux, X64, dev ] | |
needs: [ docker-build-and-push ] | |
if: ${{ needs.docker-build-and-push.result == 'success' }} | |
steps: | |
- name: 도커 허브 리포지토리에서 최신 이미지 가져오기 | |
run: | | |
sudo docker login --username ${{ secrets.DEV_DOCKER_HUB_USERNAME }} --password ${{ secrets.DEV_DOCKER_HUB_ACCESS_TOKEN }} | |
sudo docker pull ${{ secrets.DEV_DOCKER_HUB_REPOSITORY }}:${{ secrets.DEV_IMAGE_TAG }} | |
- name: blue green 배포 | |
run: | | |
sudo chmod +x deploy.sh | |
sudo ./deploy.sh | |
- name: 도커 이미지 정리 | |
run: | | |
sudo docker image prune --all --force |