-
Notifications
You must be signed in to change notification settings - Fork 11
111 lines (97 loc) · 3.67 KB
/
deploy_on_dev.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
name: Deploy Django with zappa on DEV stage
on:
push:
branches: [devdev]
workflow_dispatch:
jobs:
build:
if: github.repository_owner == 'pythonkr'
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]
steps:
- uses: actions/checkout@v4
#- uses: psf/black@stable
# with:
# options: "--check --verbose"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install mysql common
run: |
sudo apt-get install -y mysql-common
# - name: Install python version
# uses: gabrielfalcao/pyenv-action@v9
# with:
# default: "${{ matrix.python }}"
# command: |
# python -m pip install --upgrade pip
# pip install pytest
# if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Setup Virtualenv
run: |
pip install virtualenv
- name: Create Virtualenv
run: |
virtualenv zappa-env
# - name: Activate Virtualenv
# run: |
# source ./zappa-env/bin/activate
- name: Install dependencies
run: |
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
# Retrieve repo name
- name: Get current date and repo name
id: info
run: |
echo "::set-output name=repository_name::$(echo ${{ github.repository }} | sed -e 's/${{ github.repository_owner }}\///')"
# Checkout and import zappa config
- name: Checkout secrets repo
uses: actions/checkout@v4
with:
repository: ${{ secrets.PYCONKR_SECRET_REPOSITORY }}
ssh-key: ${{ secrets.PYCONKR_SECRET_REPOSITORY_DEPLOY_KEY }}
path: secret_envs
clean: false
sparse-checkout-cone-mode: false
sparse-checkout: |
${{ steps.info.outputs.repository_name }}/zappa_settings.json
- run: mv secret_envs/${{ steps.info.outputs.repository_name }}/zappa_settings.json ./zappa_settings.json && rm -rf secret_envs
# - 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@v4
with:
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_2023_AWS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.PYCON_DEV_2023_AWS_SECRET }}
run: |
source ./zappa-env/bin/activate
zappa update dev2023
# zappa manage dev2023 "collectstatic --no-input"
- name: Collect Static Files to S3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.PYCON_DEV_2023_AWS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.PYCON_DEV_2023_AWS_SECRET }}
AWS_S3_ACCESS_KEY_ID: ${{ secrets.PYCON_DEV_2023_AWS_KEY }}
AWS_S3_SECRET_ACCESS_KEY: ${{ secrets.PYCON_DEV_2023_AWS_SECRET }}
run: |
source ./zappa-env/bin/activate
python manage.py collectstatic --no-input --settings=pyconkr.settings-dev