feat: prod 로그 #18
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: 백엔드 배포 | |
on: | |
push: | |
branches: [BE/chore/docker-test-2] | |
permissions: | |
checks: write | |
jobs: | |
build-and-push: | |
defaults: | |
run: | |
working-directory: backend | |
runs-on: ubuntu-latest | |
steps: | |
- name: 체크아웃 | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.ACTION_TOKEN }} | |
submodules: recursive | |
- name: JDK17 설치 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
cache: 'gradle' | |
- name: Gradle에 권한부여 | |
run: chmod +x gradlew | |
- name: Test 및 빌드 실행 | |
run: ./gradlew build | |
- name: 도커 메타데이터 설정 | |
id: docker_meta | |
uses: crazy-max/ghaction-docker-meta@v1 | |
with: | |
images: yigongil/spring | |
tag-semver: | | |
{{version}} | |
{{major}}.{{minor}} | |
- name: 도커 허브 로그인 | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: 도커 이미지 빌드 후 허브에 업로드 | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
file: ./backend/Dockerfile | |
platforms: linux/amd64 | |
push: true | |
tags: ${{ steps.docker_meta.outputs.tags }} | |
labels: ${{ steps.docker_meta.outputs.labels }} | |
deploy: | |
runs-on: self-hosted | |
if: ${{ needs.build-and-push.result == 'success' }} | |
needs: [ build-and-push ] | |
steps: | |
- name: 도커 풀 / 파일 실행 | |
run: | | |
cd ~ | |
sudo bash ./deploy.sh | |