Skip to content

ci-cd: mistake is resolved #26

ci-cd: mistake is resolved

ci-cd: mistake is resolved #26

name: CI/CD Pipeline
on:
pull_request:
branches: [ master ]
types: [closed]
jobs:
test:
runs-on: ubuntu-latest
services:
db:
image: postgres:latest
env:
POSTGRES_HOST: db
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
cache:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.12.1'
- name: Generate Environment Variables File for Production
run: |
cd server
echo "DEBUG=$DEBUG" >> .env
echo "SECRET_KEY=$SECRET_KEY" >> .env
echo "POSTGRES_PASSWORD=$POSTGRES_PASSWORD" >> .env
echo "SENTRY_DSN=$SENTRY_DSN" >> .env
echo "IAMPORT_KEY=$IAMPORT_KEY" >> .env
echo "IAMPORT_SECRET=$IAMPORT_SECRET" >> .env
env:
DEBUG: ${{ secrets.DEBUG }}
SECRET_KEY: ${{ secrets.SECRET_KEY }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
IAMPORT_KEY: ${{ secrets.IAMPORT_KEY }}
IAMPORT_SECRET: ${{ secrets.IAMPORT_SECRET }}
- name: Install dependencies
run: |
cd server
python -m pip install --upgrade pip
pip install -r requirements.txt
mkdir -p logs
pip install setuptools
- name: Connet to PostgreSQL
run: |
cd server
python manage.py makemigrations --settings=config.settings.prod
python manage.py migrate --settings=config.settings.prod
env:
POSTGRES_HOST: db
POSTGRES_PORT: 5432
- name: Run Django Tests
run: |
cd server
python manage.py test --settings=config.settings.prod
env:
env:
DEBUG: ${{ secrets.DEBUG }}
SECRET_KEY: ${{ secrets.SECRET_KEY }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
IAMPORT_KEY: ${{ secrets.IAMPORT_KEY }}
IAMPORT_SECRET: ${{ secrets.IAMPORT_SECRET }}
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: '20.10.0'
- name: Install NPM dependencies
run: |
cd client
npm install --legacy-peer-deps
- name: Run React Tests
run: |
cd client
npm test
deploy:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up SSH connection
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSHKEY }}
- name: Connect to Server and Deploy
run: |
ssh -o "StrictHostKeyChecking=no" [email protected] "cd /home/ehgus_dev_8621/yparkw/ypark_shop && git pull origin master&& sudo docker-compose -f docker-compose.yml -f docker-compose.prod.yml build && sudo docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d"