Skip to content

배포 파이프라인 적용 #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 29 commits into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
168075c
test
golony6449 Jan 23, 2023
5fc1719
permission test: push
golony6449 Jan 23, 2023
0c26ad2
permission test: push
golony6449 Jan 23, 2023
5e32815
permission test: push
golony6449 Jan 23, 2023
a19152c
update: mysql 의존성 추가 및 프로퍼티 지정
golony6449 Jan 27, 2023
d2e02b4
Merge pull request #1 from golony6449/feature/mysql
golony6449 Jan 27, 2023
5727f66
update: mysql 의존성 추가 및 프로퍼티 지정
golony6449 Jan 27, 2023
de1f199
Merge pull request #2 from golony6449/feature/mysql
golony6449 Jan 27, 2023
864e870
update: djangorestframework 의존성 추가
golony6449 Jan 27, 2023
adb712e
update: 개발환경 설정분리
golony6449 Jan 27, 2023
8801ed5
Merge pull request #3 from golony6449/feature/drf
golony6449 Jan 27, 2023
64c2096
update: static 파일을 S3에 저장하도록 수정 (dev, prod)
golony6449 Jan 28, 2023
59fc2bd
update: PR 머지 선결조건으로 추가할 linter 확인 추가
golony6449 Jan 28, 2023
93f618c
update: zappa CI 스크립트 작성
golony6449 Jan 29, 2023
d2cd8bc
update: zappa CI 스크립트 작성 (zappa 의존성 추가)
golony6449 Jan 29, 2023
9febb40
Merge pull request #4 from golony6449/feature/setup
golony6449 Jan 29, 2023
76991b5
lint: 코드 포멧 수정
golony6449 Jan 29, 2023
4f83f0d
Merge pull request #5 from golony6449/feature/setup
golony6449 Jan 29, 2023
7975f44
update: 환경변수 설정 스크립트 파일명 변경
golony6449 Jan 29, 2023
0828171
Merge pull request #6 from golony6449/feature/setup
golony6449 Jan 29, 2023
f29743a
update: 환경변수 설정 스크립트 permission 수정
golony6449 Jan 29, 2023
5e5b9b0
Merge pull request #7 from golony6449/feature/setup
golony6449 Jan 29, 2023
b83b8e7
update: 환경변수 설정 스크립트 permission 수정
golony6449 Jan 29, 2023
f154c17
Merge remote-tracking branch 'upstream/devdev' into devdev
golony6449 Jan 29, 2023
95c7af1
update: 환경변수 설정 스크립트 yaml syntax 수정
golony6449 Jan 29, 2023
aad25bb
update: 환경변수 설정 스크립트 변수 수정
golony6449 Jan 29, 2023
b2b8725
update: 환경별 settings.py 수정
golony6449 Jan 30, 2023
880cd2c
update: github action 스크립트 수정
golony6449 Jan 30, 2023
6dea40d
update: github action 스크립트 수정 (테스트 비활성화)
golony6449 Jan 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
### 목표
*

### 작업내용
*

### 유의사항
* 리뷰어는 `PyConKR-2023`을 지정 해 주세요.
* 작업한 내용을 상세하게 작성해주세요.
42 changes: 21 additions & 21 deletions .github/workflows/deploy_on_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]
python-version: [3.9]

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -42,17 +42,18 @@ jobs:

- name: Create Virtualenv
run: |
virtualenv pyconweb2022-zappa
virtualenv zappa-env

# - name: Activate Virtualenv
# run: |
# source ./pyconweb2022-zappa/bin/activate
# source ./zappa-env/bin/activate

- name: Install dependencies
run: |
source ./pyconweb2022-zappa/bin/activate
source ./zappa-env/bin/activate
python -m pip install --upgrade pip
pip install pytest
pip install zappa
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi

# Pull request dose not get the gitub action secrets
Expand All @@ -65,32 +66,31 @@ jobs:

- name: update pyconkr-secretes
run: |
chmod 775 ./update_secrets.sh
./update_secrets.sh

- name: Test with Django Test
run: |
source ./pyconweb2022-zappa/bin/activate
cd pyconweb2022
python manage.py test

- name: Test with pytest
run: |
source ./pyconweb2022-zappa/bin/activate
pytest pyconweb2022
# - name: Test with Django Test
# run: |
# source ./zappa-env/bin/activate
# python manage.py test
#
# - name: Test with pytest
# run: |
# source ./zappa-env/bin/activate
# pytest .

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.PYCON_DEV_2021_AWS_KEY }}
aws-secret-access-key: ${{ secrets.PYCON_DEV_2021_AWS_SECRET }}
aws-access-key-id: ${{ secrets.PYCON_DEV_2023_AWS_KEY }}
aws-secret-access-key: ${{ secrets.PYCON_DEV_2023_AWS_SECRET }}
aws-region: ap-northeast-2

- name: Zappa Deploy(Update)
env:
AWS_ACCESS_KEY_ID: ${{ secrets.PYCON_DEV_2021_AWS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.PYCON_DEV_2021_AWS_SECRET }}
AWS_ACCESS_KEY_ID: ${{ secrets.PYCON_DEV_2023_AWS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.PYCON_DEV_2023_AWS_SECRET }}
run: |
source ./pyconweb2022-zappa/bin/activate
cd pyconweb2022
zappa update dev
source ./zappa-env/bin/activate
zappa update dev2023
# zappa manage dev collectstatic
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]
python-version: [3.9]

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -40,17 +40,18 @@ jobs:

- name: Create Virtualenv
run: |
virtualenv pyconweb2022-zappa
virtualenv zappa-env

# - name: Activate Virtualenv
# run: |
# source ./pyconweb2022-zappa/bin/activate

- name: Install dependencies
run: |
source ./pyconweb2022-zappa/bin/activate
source ./zappa-env/bin/activate
python -m pip install --upgrade pip
pip install pytest
pip install zappa
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi

# Pull request dose not get the gitub action secrets
Expand All @@ -63,26 +64,31 @@ jobs:

- name: update pyconkr-secretes
run: |
chmod 775 ./update_secrets.sh
./update_secrets.sh

- name: Test with pytest
run: |
source ./pyconweb2022-zappa/bin/activate
pytest pyconweb2022
# - name: Test with Django Test
# run: |
# source ./zappa-env/bin/activate
# python manage.py test
#
# - name: Test with pytest
# run: |
# source ./zappa-env/bin/activate
# pytest .

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.PYCON_DEV_2021_AWS_KEY }}
aws-secret-access-key: ${{ secrets.PYCON_DEV_2021_AWS_SECRET }}
aws-access-key-id: ${{ secrets.PYCON_DEV_2023_AWS_SECRET }}
aws-secret-access-key: ${{ secrets.PYCON_DEV_2023_AWS_SECRET }}
aws-region: ap-northeast-2

- name: Zappa Deploy(Update)
env:
AWS_ACCESS_KEY_ID: ${{ secrets.PYCON_DEV_2021_AWS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.PYCON_DEV_2021_AWS_SECRET }}
AWS_ACCESS_KEY_ID: ${{ secrets.PYCON_DEV_2023_AWS_SECRET }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.PYCON_DEV_2023_AWS_SECRET }}
run: |
source ./pyconweb2022-zappa/bin/activate
cd pyconweb2022
zappa update production
source ./zappa-env/bin/activate
zappa update prod2023
# zappa manage production collectstatic
17 changes: 17 additions & 0 deletions .github/workflows/pull-request-merge-precondition.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Pull Request Merge Precondition

on:
pull_request:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]

steps:
- uses: actions/checkout@v2
- uses: psf/black@stable
with:
options: "--check --verbose"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/.idea
/db.sqlite3
23 changes: 23 additions & 0 deletions pyconkr/settings-dev.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import os
from pyconkr.settings import *

DEBUG = True

# RDS
DATABASES = {
"default": {
"ENGINE": "mysql.connector.django",
"NAME": os.getenv("AWS_RDS_DATABASE"),
"USER": os.getenv("AWS_RDS_USER_ID"),
"PASSWORD": os.getenv("AWS_RDS_PW"),
"HOST": os.getenv("AWS_RDS_HOST"),
"PORT": os.getenv("AWS_RDS_PORT"),
}
}

# django-storages: S3
DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
STATICFILES_STORAGE = "storages.backends.s3boto3.S3StaticStorage"
AWS_S3_ACCESS_KEY_ID = os.getenv("AWS_S3_ACCESS_KEY_ID")
AWS_S3_SECRET_ACCESS_KEY = os.getenv("AWS_S3_SECRET_ACCESS_KEY")
AWS_STORAGE_BUCKET_NAME = "pyconkr-api-v2-static-dev"
22 changes: 22 additions & 0 deletions pyconkr/settings-prod.py
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
import os
from pyconkr.settings import *

DEBUG = False

# RDS
DATABASES = {
"default": {
"ENGINE": "mysql.connector.django",
"NAME": os.getenv("AWS_RDS_DATABASE"),
"USER": os.getenv("AWS_RDS_USER_ID"),
"PASSWORD": os.getenv("AWS_RDS_PW"),
"HOST": os.getenv("AWS_RDS_HOST"),
"PORT": os.getenv("AWS_RDS_PORT"),
}
}

# django-storages: S3
DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
STATICFILES_STORAGE = "storages.backends.s3boto3.S3StaticStorage"
AWS_S3_ACCESS_KEY_ID = os.getenv("AWS_S3_ACCESS_KEY_ID")
AWS_S3_SECRET_ACCESS_KEY = os.getenv("AWS_S3_SECRET_ACCESS_KEY")
AWS_STORAGE_BUCKET_NAME = "pyconkr-api-v2-static"
8 changes: 5 additions & 3 deletions pyconkr/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
# djangorestframework
"rest_framework",
]

MIDDLEWARE = [
Expand Down Expand Up @@ -103,16 +105,16 @@
# Internationalization
# https://docs.djangoproject.com/en/4.1/topics/i18n/

LANGUAGE_CODE = "en-us"
LANGUAGE_CODE = "ko-KR"

TIME_ZONE = "UTC"
TIME_ZONE = "Asia/Seoul"

USE_I18N = True

USE_TZ = True


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

STATIC_URL = "static/"
Expand Down
3 changes: 2 additions & 1 deletion pyconkr/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.urls import path, include

urlpatterns = [
path("api-auth/", include("rest_framework.urls")),
path("admin/", admin.site.urls),
]
Binary file modified requirements.txt
Binary file not shown.
13 changes: 13 additions & 0 deletions update_secrets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

# REPO_BASE_URL="github.com/pythonkr/pyconkr-secrets.git"
# REPO_URL="https://${REPO_BASE_URL}"
REPO_URL="[email protected]:pythonkr/pyconkr-secrets.git"

# checkout repo from github
mkdir -p .temp
pushd .temp
git clone --depth=1 ${REPO_URL}
rsync -arv ./pyconkr-secrets/pyconkr-api-v2/ ..
popd
rm -rf ./.temp