-
Notifications
You must be signed in to change notification settings - Fork 0
124 lines (105 loc) · 3.64 KB
/
ci-cd-pipeline.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: CI/CD Pipeline
on:
pull_request:
branches: [ master ]
types: [closed]
jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:latest
env:
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
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.local
python manage.py migrate --settings=config.settings.local
env:
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
POSTGRES_HOST: localhost
POSTGRES_PORT: 5432
- name: Run Django Tests
run: |
cd server
python manage.py test --settings=config.settings.local
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"