Skip to content

Commit

Permalink
인프라 문제 해결될 때 까지 CI/CD 비활성화
Browse files Browse the repository at this point in the history
  • Loading branch information
Scanf-s committed Jan 23, 2025
1 parent ab26aba commit 75ac665
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 140 deletions.
134 changes: 67 additions & 67 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,67 +1,67 @@
name: Check code quality, run test code

on:
pull_request:
branches:
- main
types:
- closed

jobs:
deploy:
name: Deploy Docker image to ECR and Run docker image in EC2 instance
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest

steps:
- name: 코드 Checkout
uses: actions/checkout@v4

- name: AWS Credentials 가져오기
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: AWS ECR 로그인
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: 백엔드 도커 이미지 생성 및 배포
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY_NAME }}
IMAGE_TAG: ${{ github.sha }}
run: |
# 도커 이미지 생성
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:latest .
# ECR로 도커 이미지 PUSH
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
- name: EC2에 배포 및 백엔드 어플리케이션 실행
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_SSH_KEY }}
script: ./deploy.sh

- name: 배포 결과 확인
if: always()
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_SSH_KEY }}
script: |
# 컨테이너 상태 확인
if docker ps | grep -q "${{ secrets.ECR_REPOSITORY_NAME }}"; then
echo "Container is running successfully"
exit 0
else
echo "Container is not running"
exit 1
fi
#name: Check code quality, run test code
#
#on:
# pull_request:
# branches:
# - main
# types:
# - closed
#
#jobs:
# deploy:
# name: Deploy Docker image to ECR and Run docker image in EC2 instance
# if: github.event.pull_request.merged == true
# runs-on: ubuntu-latest
#
# steps:
# - name: 코드 Checkout
# uses: actions/checkout@v4
#
# - name: AWS Credentials 가져오기
# uses: aws-actions/configure-aws-credentials@v4
# with:
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# aws-region: ${{ secrets.AWS_REGION }}
#
# - name: AWS ECR 로그인
# id: login-ecr
# uses: aws-actions/amazon-ecr-login@v2
#
# - name: 백엔드 도커 이미지 생성 및 배포
# env:
# ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
# ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY_NAME }}
# IMAGE_TAG: ${{ github.sha }}
# run: |
# # 도커 이미지 생성
# docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:latest .
#
# # ECR로 도커 이미지 PUSH
# docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
# docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
#
# - name: EC2에 배포 및 백엔드 어플리케이션 실행
# uses: appleboy/ssh-action@master
# with:
# host: ${{ secrets.EC2_HOST }}
# username: ${{ secrets.EC2_USERNAME }}
# key: ${{ secrets.EC2_SSH_KEY }}
# script: ./deploy.sh
#
# - name: 배포 결과 확인
# if: always()
# uses: appleboy/ssh-action@master
# with:
# host: ${{ secrets.EC2_HOST }}
# username: ${{ secrets.EC2_USERNAME }}
# key: ${{ secrets.EC2_SSH_KEY }}
# script: |
# # 컨테이너 상태 확인
# if docker ps | grep -q "${{ secrets.ECR_REPOSITORY_NAME }}"; then
# echo "Container is running successfully"
# exit 0
# else
# echo "Container is not running"
# exit 1
# fi
146 changes: 73 additions & 73 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -1,73 +1,73 @@
name: Integration Test

on:
pull_request:
branches:
- main
types:
- opened
- reopened
- synchronize

jobs:
test:
name: Django API Test
runs-on: ubuntu-latest

steps:
- name: 캐시 무효화
uses: actions/cache@v4
with:
path: |
~/.cache/pypoetry
~/.cache/pip
key: ${{ runner.os }}-poetry-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-poetry-
- name: 코드 Checkout
uses: actions/checkout@v4

- uses: actions/setup-python@v3
with:
python-version: "3.12"

- name: Poetry 설치
run: |
curl -sSL https://install.python-poetry.org | python3 -
export PATH="$HOME/.local/bin:$PATH"
- name: 의존성 설치
run: |
poetry install --no-root
shell: bash

- name: 코드 스타일 검사 (isort)
run: |
poetry run isort . --check-only
- name: 코드 스타일 검사 (black)
run: |
poetry run black . --check
- name: 임시 데이터베이스 Migration
env:
DJANGO_SETTINGS_MODULE: "config.settings"
DJANGO_DEBUG_MODE: true
UPCY_SECRET_KEY: "test123123123123123123123" # 진짜 SECRET 키 아닙니다.
run: |
poetry run python manage.py migrate
- name: Django 테스트 실행
env:
DJANGO_SETTINGS_MODULE: "config.settings"
DJANGO_DEBUG_MODE: true
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_STORAGE_BUCKET_NAME: ${{ secrets.AWS_STORAGE_BUCKET_NAME }}
UPCY_SECRET_KEY: "test123123123123123123123" # 진짜 SECRET 키 아닙니다.
run: |
poetry run python manage.py test users.tests.user_tests # User 모듈 테스트 실행
poetry run python manage.py test users.tests.reformer_tests # Reformer 모듈 테스트 실행
poetry run python manage.py test market # Market, Service 테스트 실행
poetry run python manage.py test order # Order 모듈 테스트 실행
#name: Integration Test
#
#on:
# pull_request:
# branches:
# - main
# types:
# - opened
# - reopened
# - synchronize
#
#jobs:
# test:
# name: Django API Test
# runs-on: ubuntu-latest
#
# steps:
# - name: 캐시 무효화
# uses: actions/cache@v4
# with:
# path: |
# ~/.cache/pypoetry
# ~/.cache/pip
# key: ${{ runner.os }}-poetry-${{ github.run_id }}
# restore-keys: |
# ${{ runner.os }}-poetry-
#
# - name: 코드 Checkout
# uses: actions/checkout@v4
#
# - uses: actions/setup-python@v3
# with:
# python-version: "3.12"
#
# - name: Poetry 설치
# run: |
# curl -sSL https://install.python-poetry.org | python3 -
# export PATH="$HOME/.local/bin:$PATH"
#
# - name: 의존성 설치
# run: |
# poetry install --no-root
# shell: bash
#
# - name: 코드 스타일 검사 (isort)
# run: |
# poetry run isort . --check-only
#
# - name: 코드 스타일 검사 (black)
# run: |
# poetry run black . --check
#
# - name: 임시 데이터베이스 Migration
# env:
# DJANGO_SETTINGS_MODULE: "config.settings"
# DJANGO_DEBUG_MODE: true
# UPCY_SECRET_KEY: "test123123123123123123123" # 진짜 SECRET 키 아닙니다.
# run: |
# poetry run python manage.py migrate
#
# - name: Django 테스트 실행
# env:
# DJANGO_SETTINGS_MODULE: "config.settings"
# DJANGO_DEBUG_MODE: true
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# AWS_STORAGE_BUCKET_NAME: ${{ secrets.AWS_STORAGE_BUCKET_NAME }}
# UPCY_SECRET_KEY: "test123123123123123123123" # 진짜 SECRET 키 아닙니다.
# run: |
# poetry run python manage.py test users.tests.user_tests # User 모듈 테스트 실행
# poetry run python manage.py test users.tests.reformer_tests # Reformer 모듈 테스트 실행
# poetry run python manage.py test market # Market, Service 테스트 실행
# poetry run python manage.py test order # Order 모듈 테스트 실행

0 comments on commit 75ac665

Please sign in to comment.