Update docker-image.yml #6
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: Docker Image CI | ||
on: | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
branches: [ "master" ] | ||
jobs: | ||
build-backend: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
# JDK 17 설치 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' # Temurin JDK 배포판 사용 | ||
# Gradlew 실행 권한 부여 | ||
- name: Grant execute permission for gradlew | ||
working-directory: ./backend | ||
run: | | ||
chmod +x gradlew | ||
# Gradle 빌드 | ||
- name: Gradle Build | ||
working-directory: ./backend | ||
run: | | ||
./gradlew build | ||
# Docker 이미지 빌드 | ||
- name: Build Backend Docker image | ||
working-directory: ./backend | ||
run: | | ||
docker build -t hongboemsun682/backend:latest . | ||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
- name: Push Backend Docker image to Docker Hub | ||
run: | | ||
docker push hongboemsun682/backend:latest | ||
build-frontend: | ||
runs-on: ubuntu-latest # Ubuntu 최신 버전에서 실행 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 # GitHub 저장소에서 코드를 클론 | ||
- name: .env setting | ||
run: | | ||
echo "LIVEBLOCKS_SECRET_KEY=${{ secrets.LIVEBLOCKS_SECRET_KEY }}" >> .env | ||
echo "NEXT_PUBLIC_API_TOKEN=${{ secrets.NEXT_PUBLIC_API_TOKEN }}" >> .env | ||
echo "NEXT_PUBLIC_BACKEND_URL=${{ secrets.NEXT_PUBLIC_BACKEND_URL }}" >> .env | ||
echo "NEXT_PUBLIC_BACKEND_URL_D=${{ secrets.NEXT_PUBLIC_BACKEND_URL_D }}" >> .env | ||
# frontend 디렉토리에서 Docker 이미지 빌드 | ||
- name: Build Frontend Docker image | ||
working-directory: ./frontend # frontend 폴더에서 작업 | ||
run: | | ||
docker build -t hongboemsun682/frontend:latest . # frontend 이미지를 빌드 | ||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
- name: Push Frontend Docker image to Docker Hub | ||
run: | | ||
docker push hongboemsun682/frontend:latest # frontend 이미지를 Docker Hub에 푸시 |