-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (90 loc) · 2.76 KB
/
deployment.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
name: Test and Deploy
on:
push:
branches: [main, dev, test]
jobs:
run-tests:
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE
- name: Check out repository
uses: actions/checkout@v3
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.SLS_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SLS_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
# Set up Python 3.9 environment
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
# Install Python dependencies
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
# Run tests
- name: Run tests
run: python -m pytest
deploy:
needs:
- run-tests
runs-on: ubuntu-latest
steps:
# Configure the deployment stage name from the active branch
- name: Set up deployment stage name
id: deployment-stage
run: |
echo "DEPLOY_STAGE=${{ fromJSON('{"main":"prod","dev":"dev","test":"test"}')[github.ref_name] }}" >> $GITHUB_ENV
- name: Verify Stage
run: echo $DEPLOY_STAGE
# Checks-out the repository under $GITHUB_WORKSPACE
- uses: actions/checkout@v2
# Configure Auth0 secrets
- name: Create public_key file
run: |
cat > /home/runner/work/photonranch-api/photonranch-api/public_key << EOF
-----BEGIN CERTIFICATE-----
${{ secrets.AUTH0_PUBLIC_KEY }}
-----END CERTIFICATE-----
EOF
- name: Create Auth0 secrets file
run: |
cat > /home/runner/work/photonranch-api/photonranch-api/secrets.json << EOF
{
"AUTH0_CLIENT_ID": "${{ secrets.AUTH0_CLIENT_ID }}"
}
EOF
# Set up Node
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: 18.x
# Read public key
- name: Read Public Key
run: |
{
echo "PUBLIC_KEY<<EOF"
cat ./public_key
echo EOF
} >> $GITHUB_ENV
# Set up Python 3.9 environment
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
# Install serverless
- name: Install Serverless
run: npm install -g serverless
# Install Node dependencies
- name: Set up Environment
run: npm ci --include=dev
# Deploy to stage
- name: Serverless Deploy
run: sls deploy --stage $DEPLOY_STAGE
env:
SERVERLESS_ACCESS_KEY: ${{ secrets.SLS_SECRET_KEY }}
AWS_ACCESS_KEY_ID: ${{ secrets.SLS_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.SLS_AWS_SECRET_ACCESS_KEY }}