Skip to content

[feat #91] 알림 목록/읽기 API (#97) #55

[feat #91] 알림 목록/읽기 API (#97)

[feat #91] 알림 목록/읽기 API (#97) #55

Workflow file for this run

name: CD Backend
on:
push:
branches: [ "main", "dev" ]
permissions:
contents: read
jobs:
build-and-push-image:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
# 자바 버전 설정
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
# main 경로 application.yml 파일 생성
- name: Generate application.yml
run: |
mkdir -p ./src/main/resources
echo "${{ secrets.MAIN_APPLICATION_YML }}" | base64 -d > ./src/main/resources/application.yml
# gradle 권한 부여
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
shell: bash
# 빌드 시 캐시 적용
- name: Gradle Caching
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
# 빌드
- name: Build with Gradle
run: ./gradlew build -x test
# 도커 허브 로그인
- name: Docker Hub Login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# 도커 이미지 빌드 및 푸시
- name: docker image build and push
run: |
docker build -f Dockerfile -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_APP_NAME }} .
docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_APP_NAME }}
deploy:
needs: build-and-push-image
runs-on: ubuntu-latest
steps:
# 서버 백그라운드 실행
- name: pull image and run container
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_KEY }}
port: ${{ secrets.EC2_PORT }}
script: |
cd compose
docker rm -f $(docker ps -qa)
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_APP_NAME }}
docker-compose up -d
docker system prune -f