diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..cb922f7 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,9 @@ +### 목표 +* + +### 작업내용 +* + +### 유의사항 +* 리뷰어는 `PyConKR-2023`을 지정 해 주세요. +* 작업한 내용을 상세하게 작성해주세요. \ No newline at end of file diff --git a/.github/workflows/deploy_on_dev.yml b/.github/workflows/deploy_on_dev.yml index 518daf3..a844f2e 100644 --- a/.github/workflows/deploy_on_dev.yml +++ b/.github/workflows/deploy_on_dev.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.8] + python-version: [3.9] steps: - uses: actions/checkout@v2 @@ -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 @@ -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 \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy_on_prod.yml similarity index 72% rename from .github/workflows/deploy.yml rename to .github/workflows/deploy_on_prod.yml index 15e0fc4..729a0e4 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy_on_prod.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.8] + python-version: [3.9] steps: - uses: actions/checkout@v2 @@ -40,7 +40,7 @@ jobs: - name: Create Virtualenv run: | - virtualenv pyconweb2022-zappa + virtualenv zappa-env # - name: Activate Virtualenv # run: | @@ -48,9 +48,10 @@ jobs: - 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 @@ -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 \ No newline at end of file diff --git a/.github/workflows/pull-request-merge-precondition.yml b/.github/workflows/pull-request-merge-precondition.yml new file mode 100644 index 0000000..ddf7478 --- /dev/null +++ b/.github/workflows/pull-request-merge-precondition.yml @@ -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" diff --git a/.gitignore b/.gitignore index a09c56d..8faa4d2 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /.idea +/db.sqlite3 diff --git a/pyconkr/settings-dev.py b/pyconkr/settings-dev.py new file mode 100644 index 0000000..343d2ed --- /dev/null +++ b/pyconkr/settings-dev.py @@ -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" diff --git a/pyconkr/settings-prod.py b/pyconkr/settings-prod.py index c7d5d42..1e107f6 100644 --- a/pyconkr/settings-prod.py +++ b/pyconkr/settings-prod.py @@ -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" diff --git a/pyconkr/settings.py b/pyconkr/settings.py index 5276014..6b0b6b1 100644 --- a/pyconkr/settings.py +++ b/pyconkr/settings.py @@ -37,6 +37,8 @@ "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", + # djangorestframework + "rest_framework", ] MIDDLEWARE = [ @@ -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/" diff --git a/pyconkr/urls.py b/pyconkr/urls.py index 5d31f11..ecbd711 100644 --- a/pyconkr/urls.py +++ b/pyconkr/urls.py @@ -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), ] diff --git a/requirements.txt b/requirements.txt index da7c592..e5c04b1 100644 Binary files a/requirements.txt and b/requirements.txt differ diff --git a/update_secrets.sh b/update_secrets.sh new file mode 100644 index 0000000..31e6f07 --- /dev/null +++ b/update_secrets.sh @@ -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="git@github.com: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 \ No newline at end of file