Skip to content

Commit f1bdf15

Browse files
authored
Merge pull request #8 from pythonkr/devdev
배포 파이프라인 적용
2 parents dbfe0b1 + 6dea40d commit f1bdf15

11 files changed

+133
-39
lines changed

.github/pull_request_template.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
### 목표
2+
*
3+
4+
### 작업내용
5+
*
6+
7+
### 유의사항
8+
* 리뷰어는 `PyConKR-2023`을 지정 해 주세요.
9+
* 작업한 내용을 상세하게 작성해주세요.

.github/workflows/deploy_on_dev.yml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
python-version: [3.8]
13+
python-version: [3.9]
1414

1515
steps:
1616
- uses: actions/checkout@v2
@@ -42,17 +42,18 @@ jobs:
4242
4343
- name: Create Virtualenv
4444
run: |
45-
virtualenv pyconweb2022-zappa
45+
virtualenv zappa-env
4646
4747
# - name: Activate Virtualenv
4848
# run: |
49-
# source ./pyconweb2022-zappa/bin/activate
49+
# source ./zappa-env/bin/activate
5050

5151
- name: Install dependencies
5252
run: |
53-
source ./pyconweb2022-zappa/bin/activate
53+
source ./zappa-env/bin/activate
5454
python -m pip install --upgrade pip
5555
pip install pytest
56+
pip install zappa
5657
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
5758
5859
# Pull request dose not get the gitub action secrets
@@ -65,32 +66,31 @@ jobs:
6566

6667
- name: update pyconkr-secretes
6768
run: |
69+
chmod 775 ./update_secrets.sh
6870
./update_secrets.sh
6971
70-
- name: Test with Django Test
71-
run: |
72-
source ./pyconweb2022-zappa/bin/activate
73-
cd pyconweb2022
74-
python manage.py test
75-
76-
- name: Test with pytest
77-
run: |
78-
source ./pyconweb2022-zappa/bin/activate
79-
pytest pyconweb2022
72+
# - name: Test with Django Test
73+
# run: |
74+
# source ./zappa-env/bin/activate
75+
# python manage.py test
76+
#
77+
# - name: Test with pytest
78+
# run: |
79+
# source ./zappa-env/bin/activate
80+
# pytest .
8081

8182
- name: Configure AWS Credentials
8283
uses: aws-actions/configure-aws-credentials@v1
8384
with:
84-
aws-access-key-id: ${{ secrets.PYCON_DEV_2021_AWS_KEY }}
85-
aws-secret-access-key: ${{ secrets.PYCON_DEV_2021_AWS_SECRET }}
85+
aws-access-key-id: ${{ secrets.PYCON_DEV_2023_AWS_KEY }}
86+
aws-secret-access-key: ${{ secrets.PYCON_DEV_2023_AWS_SECRET }}
8687
aws-region: ap-northeast-2
8788

8889
- name: Zappa Deploy(Update)
8990
env:
90-
AWS_ACCESS_KEY_ID: ${{ secrets.PYCON_DEV_2021_AWS_KEY }}
91-
AWS_SECRET_ACCESS_KEY: ${{ secrets.PYCON_DEV_2021_AWS_SECRET }}
91+
AWS_ACCESS_KEY_ID: ${{ secrets.PYCON_DEV_2023_AWS_KEY }}
92+
AWS_SECRET_ACCESS_KEY: ${{ secrets.PYCON_DEV_2023_AWS_SECRET }}
9293
run: |
93-
source ./pyconweb2022-zappa/bin/activate
94-
cd pyconweb2022
95-
zappa update dev
94+
source ./zappa-env/bin/activate
95+
zappa update dev2023
9696
# zappa manage dev collectstatic

.github/workflows/deploy.yml renamed to .github/workflows/deploy_on_prod.yml

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
python-version: [3.8]
11+
python-version: [3.9]
1212

1313
steps:
1414
- uses: actions/checkout@v2
@@ -40,17 +40,18 @@ jobs:
4040
4141
- name: Create Virtualenv
4242
run: |
43-
virtualenv pyconweb2022-zappa
43+
virtualenv zappa-env
4444
4545
# - name: Activate Virtualenv
4646
# run: |
4747
# source ./pyconweb2022-zappa/bin/activate
4848

4949
- name: Install dependencies
5050
run: |
51-
source ./pyconweb2022-zappa/bin/activate
51+
source ./zappa-env/bin/activate
5252
python -m pip install --upgrade pip
5353
pip install pytest
54+
pip install zappa
5455
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
5556
5657
# Pull request dose not get the gitub action secrets
@@ -63,26 +64,31 @@ jobs:
6364

6465
- name: update pyconkr-secretes
6566
run: |
67+
chmod 775 ./update_secrets.sh
6668
./update_secrets.sh
6769
68-
- name: Test with pytest
69-
run: |
70-
source ./pyconweb2022-zappa/bin/activate
71-
pytest pyconweb2022
70+
# - name: Test with Django Test
71+
# run: |
72+
# source ./zappa-env/bin/activate
73+
# python manage.py test
74+
#
75+
# - name: Test with pytest
76+
# run: |
77+
# source ./zappa-env/bin/activate
78+
# pytest .
7279

7380
- name: Configure AWS Credentials
7481
uses: aws-actions/configure-aws-credentials@v1
7582
with:
76-
aws-access-key-id: ${{ secrets.PYCON_DEV_2021_AWS_KEY }}
77-
aws-secret-access-key: ${{ secrets.PYCON_DEV_2021_AWS_SECRET }}
83+
aws-access-key-id: ${{ secrets.PYCON_DEV_2023_AWS_SECRET }}
84+
aws-secret-access-key: ${{ secrets.PYCON_DEV_2023_AWS_SECRET }}
7885
aws-region: ap-northeast-2
7986

8087
- name: Zappa Deploy(Update)
8188
env:
82-
AWS_ACCESS_KEY_ID: ${{ secrets.PYCON_DEV_2021_AWS_KEY }}
83-
AWS_SECRET_ACCESS_KEY: ${{ secrets.PYCON_DEV_2021_AWS_SECRET }}
89+
AWS_ACCESS_KEY_ID: ${{ secrets.PYCON_DEV_2023_AWS_SECRET }}
90+
AWS_SECRET_ACCESS_KEY: ${{ secrets.PYCON_DEV_2023_AWS_SECRET }}
8491
run: |
85-
source ./pyconweb2022-zappa/bin/activate
86-
cd pyconweb2022
87-
zappa update production
92+
source ./zappa-env/bin/activate
93+
zappa update prod2023
8894
# zappa manage production collectstatic
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Pull Request Merge Precondition
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
python-version: [3.8]
12+
13+
steps:
14+
- uses: actions/checkout@v2
15+
- uses: psf/black@stable
16+
with:
17+
options: "--check --verbose"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/.idea
2+
/db.sqlite3

pyconkr/settings-dev.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import os
2+
from pyconkr.settings import *
3+
4+
DEBUG = True
5+
6+
# RDS
7+
DATABASES = {
8+
"default": {
9+
"ENGINE": "mysql.connector.django",
10+
"NAME": os.getenv("AWS_RDS_DATABASE"),
11+
"USER": os.getenv("AWS_RDS_USER_ID"),
12+
"PASSWORD": os.getenv("AWS_RDS_PW"),
13+
"HOST": os.getenv("AWS_RDS_HOST"),
14+
"PORT": os.getenv("AWS_RDS_PORT"),
15+
}
16+
}
17+
18+
# django-storages: S3
19+
DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
20+
STATICFILES_STORAGE = "storages.backends.s3boto3.S3StaticStorage"
21+
AWS_S3_ACCESS_KEY_ID = os.getenv("AWS_S3_ACCESS_KEY_ID")
22+
AWS_S3_SECRET_ACCESS_KEY = os.getenv("AWS_S3_SECRET_ACCESS_KEY")
23+
AWS_STORAGE_BUCKET_NAME = "pyconkr-api-v2-static-dev"

pyconkr/settings-prod.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,23 @@
1+
import os
2+
from pyconkr.settings import *
3+
14
DEBUG = False
5+
6+
# RDS
7+
DATABASES = {
8+
"default": {
9+
"ENGINE": "mysql.connector.django",
10+
"NAME": os.getenv("AWS_RDS_DATABASE"),
11+
"USER": os.getenv("AWS_RDS_USER_ID"),
12+
"PASSWORD": os.getenv("AWS_RDS_PW"),
13+
"HOST": os.getenv("AWS_RDS_HOST"),
14+
"PORT": os.getenv("AWS_RDS_PORT"),
15+
}
16+
}
17+
18+
# django-storages: S3
19+
DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
20+
STATICFILES_STORAGE = "storages.backends.s3boto3.S3StaticStorage"
21+
AWS_S3_ACCESS_KEY_ID = os.getenv("AWS_S3_ACCESS_KEY_ID")
22+
AWS_S3_SECRET_ACCESS_KEY = os.getenv("AWS_S3_SECRET_ACCESS_KEY")
23+
AWS_STORAGE_BUCKET_NAME = "pyconkr-api-v2-static"

pyconkr/settings.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
"django.contrib.sessions",
3838
"django.contrib.messages",
3939
"django.contrib.staticfiles",
40+
# djangorestframework
41+
"rest_framework",
4042
]
4143

4244
MIDDLEWARE = [
@@ -103,16 +105,16 @@
103105
# Internationalization
104106
# https://docs.djangoproject.com/en/4.1/topics/i18n/
105107

106-
LANGUAGE_CODE = "en-us"
108+
LANGUAGE_CODE = "ko-KR"
107109

108-
TIME_ZONE = "UTC"
110+
TIME_ZONE = "Asia/Seoul"
109111

110112
USE_I18N = True
111113

112114
USE_TZ = True
113115

114116

115-
# Static files (CSS, JavaScript, Images)
117+
# Static files (CSS, JavaScript, Images) (w/ django-storages)
116118
# https://docs.djangoproject.com/en/4.1/howto/static-files/
117119

118120
STATIC_URL = "static/"

pyconkr/urls.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
1515
"""
1616
from django.contrib import admin
17-
from django.urls import path
17+
from django.urls import path, include
1818

1919
urlpatterns = [
20+
path("api-auth/", include("rest_framework.urls")),
2021
path("admin/", admin.site.urls),
2122
]

requirements.txt

90 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)