Merge pull request #8 from KTB-6-Joing/fix/#7-summary-gen-responsedto #6
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: FastAPI CI Pipeline | |
on: | |
push: | |
branches: [ "develop" ] | |
jobs: | |
quality-and-build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
cache: 'pip' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Build Docker image | |
run: | | |
docker build -t joing-genai:latest . | |
- name: Verify container starts | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: ap-northeast-2 | |
run: | | |
docker run -d \ | |
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \ | |
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \ | |
-e AWS_REGION=$AWS_REGION \ | |
--name joing-ai-test-container -p 8000:8000 joing-genai:latest | |
# 컨테이너 실행 대기 | |
sleep 30 | |
# 컨테이너 상태 확인 | |
CONTAINER_STATUS=$(docker inspect joing-ai-test-container --format='{{.State.Status}}') | |
if [ "$CONTAINER_STATUS" != "running" ]; then | |
echo "Container failed to start. Status: $CONTAINER_STATUS" | |
docker logs joing-ai-test-container | |
exit 1 | |
fi | |
# Health Check | |
HEALTH_CHECK=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8000/ready || echo "failed") | |
if [ "$HEALTH_CHECK" != "200" ]; then | |
echo "Health check failed. Status code: $HEALTH_CHECK" | |
docker logs joing-ai-test-container | |
exit 1 | |
fi | |
echo "Container successfully started ..." | |
# 빌드 결과 알림 | |
- name: Send Discord Notification - Success | |
if: success() | |
uses: sarisia/actions-status-discord@v1 | |
with: | |
webhook: ${{ secrets.DISCORD_WEBHOOK }} | |
title: "빌드 성공!!!" | |
description: | | |
**Branch**: ${{ github.ref_name }} | |
**Build Number**: ${{ github.run_number }} | |
color: 0x28A745 # Color Expression: 'GREEN' | |
username: JOING CI BOT | |
- name: Send Discord Notification - Failure | |
if: failure() | |
uses: sarisia/actions-status-discord@v1 | |
with: | |
webhook: ${{ secrets.DISCORD_WEBHOOK }} | |
title: "빌드 실패..." | |
description: | | |
**Branch**: ${{ github.ref_name }} | |
**Build Number**: ${{ github.run_number }} | |
**Action URL**: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
color: 0xDC3545 # Color Expression: 'RED' | |
username: JOING CI BOT | |
- name: Cleanup | |
if: always() | |
run: | | |
docker stop joing-ai-test-container || true | |
docker rm joing-ai-test-container || true |