728x90
반응형
카카오톡 로그인 성공 시 홈페이지로 redirect하게 수정
main branch에 올라가면 CI/CD Docker 수행
Bulid와 Deploy 수행
name: CI/CD Docker
# 트리거를 수행할 브랜치를 지정합니다.
on:
push:
branches: [main]
# 환경설정
env:
DOCKER_IMAGE: ghcr.io/${{ github.actor }}/storify-be-dev
VERSION: ${{ github.sha }}
NAME: storify-be-dev
jobs:
test:
name: Run Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20' # 프로젝트에 맞는 Node.js 버전으로 설정
- name: Install dependencies
run: npm install
# - name: Run Jest tests
# run: npx jest users.controller.spec.ts
# 빌드 Job
build:
name: Build
# needs: test
runs-on: ubuntu-latest
steps:
# github repository에서 checkout
- uses: actions/checkout@v2
# docker build 수행
- name: Set up docker buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Cache docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ env.VERSION }}
restore-keys: |
${{ runner.os }}-buildx-
# GitHub 컨테이너 레지스트리에 로그인 후 빌드 & 푸시
- name: Login to jinjung0101
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: ${{ env.DOCKER_IMAGE }}:latest
# 배포 Job
deploy:
needs: build # build 후에 실행되도록 정의
name: Deploy
runs-on: [self-hosted, label-storify-be-dev] # AWS ./configure에서 사용할 label명
steps:
- name: Login to jinjung0101
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_TOKEN }}
# 3000 -> 80 포트로 수행하도록 지정
- name: Docker run
run: |
docker stop ${{ env.NAME }} || true
docker rm ${{ env.NAME }} || true
docker rmi ${{ env.DOCKER_IMAGE }}:latest || true
docker pull ${{ env.DOCKER_IMAGE }}:latest
docker run -d -p 80:3000 --name storify-be-dev \
-e "DB_URL=${{ secrets.DB_URL }}" \
-e "JWT_ACCESS_SECRET=${{ secrets.JWT_ACCESS_SECRET }}" \
-e "JWT_REFRESH_SECRET=${{ secrets.JWT_REFRESH_SECRET }}" \
-e "JWT_RESET_SECRET=${{ secrets.JWT_RESET_SECRET }}" \
-e "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}" \
-e "HUGGINFACE_API_KEY=${{ secrets.HUGGINFACE_API_KEY }}" \
-e "AWS_ACCESS_KEY=${{ secrets.AWS_ACCESS_KEY }}" \
-e "AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }}" \
-e "AWS_S3_BUCKET_NAME=${{ secrets.AWS_S3_BUCKET_NAME }}" \
-e "AWS_REGION=${{ secrets.AWS_REGION }}" \
-e "MAIL_USER=${{ secrets.MAIL_USER }}" \
-e "MAIL_PASS=${{ secrets.MAIL_PASS }}" \
-e "TELEGRAM_BOT_TOKEN=${{ secrets.TELEGRAM_BOT_TOKEN }}" \
-e "TELEGRAM_CHAT_ID=${{ secrets.TELEGRAM_CHAT_ID }}" \
-e "TELEGRAM_CHANNEL_ID=${{ secrets.TELEGRAM_CHANNEL_ID }}" \
-e "KAKAO_REST_API_KEY=${{ secrets.KAKAO_REST_API_KEY }}" \
-e "KAKAO_REDIRECT_URI=${{ secrets.KAKAO_REDIRECT_URI }}" \
-e "GOOGLE_CLIENT_ID=${{ secrets.GOOGLE_CLIENT_ID }}" \
-e "GOOGLE_CLIENT_SECRET=${{ secrets.GOOGLE_CLIENT_SECRET }}" \
-e "GOOGLE_REDIRECT_URI=${{ secrets.GOOGLE_REDIRECT_URI }}" \
-e "ADMIN=${{ secrets.ADMIN }}" \
-e "PASSWORD=${{ secrets.PASSWORD }}" \
${{ env.DOCKER_IMAGE }}:latest
728x90
반응형
'Storify' 카테고리의 다른 글
STORIFY (0215) - session 적용 (0) | 2024.02.16 |
---|---|
STORIFY(0214) - 프로젝트 회고 (0) | 2024.02.14 |
STORIFY (0212) - Docker CI/CD (0) | 2024.02.12 |
STORIFY (0208) - swagger 접근 제어, local docker 테스트 (0) | 2024.02.08 |
STORIFY (0207) - .env 요청 시도 (0) | 2024.02.07 |