feat: 프로메테우스 의존성 추가 (#255) #98
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: CD Pipeline | |
on: | |
push: | |
branches: [ main ] | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
services: | |
redis: | |
image: redis | |
ports: | |
- 6379:6379 | |
env: | |
DB_URL: ${{ secrets.DB_URL }} | |
DB_USERNAME: ${{ secrets.DB_USERNAME }} | |
DB_PASSWORD: ${{ secrets.DB_PASSWORD }} | |
REDIS_HOST: ${{ secrets.REDIS_HOST}} | |
REDIS_PORT: ${{ secrets.REDIS_PORT }} | |
NAVER_CLIENT_ID: ${{ secrets.NAVER_CLIENT_ID }} | |
NAVER_CLIENT_SECRET: ${{ secrets.NAVER_CLIENT_SECRET }} | |
NAVER_SCOPE: ${{ secrets.NAVER_SCOPE }} | |
NAVER_REDIRECT_URL: ${{ secrets.NAVER_REDIRECT_URL }} | |
JWT_SECRET: ${{ secrets.JWT_SECRET }} | |
FRONT_URL: ${{ secrets.FRONT_URL }} | |
BACK_URL: ${{ secrets.BACK_URL }} | |
BUCKET_NAME: ${{ secrets.BUCKET_NAME }} | |
BUCKET_REGION: ${{ secrets.BUCKET_REGION }} | |
IMG_BASE_URL: ${{ secrets.BASE_URL }} | |
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }} | |
S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY }} | |
DEFAULT_IMG_URL: ${{ secrets.DEFAULT_IMG_URL }} | |
APP_DEVELOP_MODE: ${{ secrets.APP_DEVELOP_MODE }} | |
ELASTIC_URI=localhost: ${{ secrets.ELASTIC_URI }} | |
ELASTIC_USERNAME: ${{ secrets.ELASTIC_USERNAME }} | |
ELASTIC_PASSWORD: ${{ secrets.ELASTIC_PASSWORD }} | |
steps: | |
- name: Github Repository 파일 불러오기 | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: JDK 21 버전 설치 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: temurin | |
java-version: 21 | |
- name: Gradle 캐싱 | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: 빌드 권한 부여 | |
run: chmod +x ./gradlew | |
shell: bash | |
- name: 빌드 및 테스트 | |
run: ./gradlew build | |
- name: 도커 허브 로그인 | |
run: echo "${{ secrets.DOCKER_ACCESS_TOKEN }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin | |
- name: 도커 이미지 빌드및 Push | |
run: | | |
docker build -t 7zrv/somemore:${GITHUB_SHA::7} -t 7zrv/somemore:latest . | |
docker push 7zrv/somemore:${GITHUB_SHA::7} | |
docker push 7zrv/somemore:latest | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build-and-push | |
steps: | |
- name: SSH 연결을 통한 EC2 배포 | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.EC2_HOST }} | |
username: ${{ secrets.EC2_USERNAME }} | |
key: ${{ secrets.EC2_SSH_KEY }} | |
port: 22 | |
script: | | |
cd somemore | |
sudo ./deploy.sh |