Skip to content

후기 좋아요 토글 기능 추가 #94

후기 좋아요 토글 기능 추가

후기 좋아요 토글 기능 추가 #94

Workflow file for this run

# 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 with Gradle
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build-docker-image: #ci
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
# Java 17 설정
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
# application-secret.yml 생성
- name: make application-secret.yml
run: |
touch ./src/main/resources/application-secret.yml
echo "${{ secrets.APPLICATION_SECRET }}" > ./src/main/resources/application-secret.yml
shell: bash
# Spring boot Application build
- name: Build with Gradle 8.5
run: gradle build
# DockerHub 로그인
- name: docker login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
# Docker Image build
- name : docker image build
run: docker build --platform linux/amd64 -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPO }} .
# DockerHub 이미지 push
- name: dockerhub push
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPO }}
run-docker-image-on-ec2: #cd
needs: build-docker-image
runs-on: self-hosted
steps:
# 최근 이미지 pull
- name: docker pull
run: sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPO }}
# 기존 container 중지
- name: docker stop container
run: sudo docker stop $(sudo docker ps -q) 2>/dev/null || true
# 3. 최신 이미지를 컨테이너화하여 실행
- name: docker run new container
run: sudo docker run --name ${{ secrets.DOCKERHUB_REPO }} --rm -d -p 8080:8080 ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPO }}
# 4. 미사용 이미지 정리
- name: delete old docker image
run: sudo docker system prune -f