Skip to content

[develop] merge to main #27

[develop] merge to main

[develop] merge to main #27

Workflow file for this run

name: prod-CI
on:
pull_request:
branches: [ "main" ]
push:
branches: [ "main" ]
jobs:
prod-ci:
# Using Environment - prod 환경
environment: prod
# Operating system - ubuntu-22.04
runs-on: ubuntu-22.04
permissions:
contents: read
steps:
# Checkout - 가상 머신에 체크아웃
- name: Checkout code
uses: actions/checkout@v3
# JDK setting - JDK 17 설정
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
# gradle caching - 빌드 시간 향상
- 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-
# Inject environment variables - 환경 변수를 yml 파일에 주입
- name: Inject environment variables into application-prod.yml
env:
PROD_DB_URL: ${{ secrets.PROD_DB_URL }}
PROD_DB_USERNAME: ${{ secrets.PROD_DB_USERNAME }}
PROD_DB_PASSWORD: ${{ secrets.PROD_DB_PASSWORD }}
PROD_JWT_SECRET: ${{ secrets.PROD_JWT_SECRET }}
PROD_KAKAO_CLIENT_ID: ${{ secrets.PROD_KAKAO_CLIENT_ID }}
PROD_KAKAO_CLIENT_SECRET: ${{ secrets.PROD_KAKAO_CLIENT_SECRET }}
PROD_KAKAO_REDIRECT_URI: ${{ secrets.PROD_KAKAO_REDIRECT_URI }}
PROD_REDIS_HOST: ${{ secrets.PROD_REDIS_HOST }}
PROD_S3_ACCESS_KEY: ${{ secrets.PROD_S3_ACCESS_KEY }}
PROD_S3_SECRET_KEY: ${{ secrets.PROD_S3_SECRET_KEY }}
run: |
cd ./src/main/resources
envsubst < application-prod.yml > application-prod.tmp.yml && mv application-prod.tmp.yml application-prod.yml
# gradle build - 테스트 없이 gradle 빌드
- name: Build with Gradle
run: |
chmod +x gradlew
./gradlew build -x test
shell: bash
# Set up Docker Buildx - Docker Buildx 설치
- name: Set up Docker Buildx
uses: docker/[email protected]
# Log in to Docker Hub - Docker Hub 로그인
- name: Log in to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.PROD_DOCKER_LOGIN_USERNAME }}
password: ${{ secrets.PROD_DOCKER_LOGIN_ACCESSTOKEN }}
# Build and push Docker image - Docker image 빌드 및 푸시
- name: Build and push Docker image
run: |
docker build --platform linux/amd64 -t donghoon0203/beat-prod .
docker push donghoon0203/beat-prod
# Trigger Jenkins job - Jenkins 작업 트리거
- name: Trigger Jenkins job
uses: appleboy/jenkins-action@master
with:
url: ${{ secrets.PROD_WEBHOOK_URL }}
user: "beat"
token: ${{ secrets.PROD_JENKINS_API_TOKEN }}
job: "beat-project"