This repository was archived by the owner on Oct 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
104 lines (104 loc) · 4.04 KB
/
deploy.yml
File metadata and controls
104 lines (104 loc) · 4.04 KB
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
# Deploys a payload to the server to get the latest data
name: Deploy to Docker
# Deploys data based off master branch
on:
push:
branches: [master]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
Python_Unit_Tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7.9
uses: actions/setup-python@v2
with:
python-version: 3.7.9
- name: Install dependencies
run: |
cd backend/python
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
cd backend/python
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Run Python Tests
run: |
cd backend/python/src/
python -m unittest
Dockerizing:
runs-on: ubuntu-latest
needs: [Python_Unit_Tests]
if: success('Python_Unit_Tests')
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7.9
uses: actions/setup-python@v2
with:
python-version: 3.7.9
- name: Install dependencies
run: |
cd backend/python
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
cd backend/python
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Docker Login
env:
DOCKER_USER: "${{ secrets.DOCKER_USER }}"
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
- name: Dockerize Backend
env:
MAILGUN: ${{ secrets.MAILGUN }}
DB: ${{ secrets.DB }}
run: |
cd backend/python
docker build --tag pubsub-backend -f ./Dockerfile.prod ./
- name: Docker push backend-python
env:
BACKEND: ${{ secrets.BACKEND }}
run: |
docker tag pubsub-backend $BACKEND
docker push $BACKEND
Deploying_To_Server:
runs-on: ubuntu-latest
needs: [Dockerizing]
if: success('Dockerizing')
steps:
- uses: actions/checkout@v2
- name: Push to server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SERVER_USER }}
password: ${{ secrets.SERVER_PASSWORD }}
script: |
sudo rm -r .env
echo "SENDER=${{ secrets.SENDER}}" > .env
echo "DOMAIN=${{ secrets.DOMAIN}}" >> .env
echo "API_KEY=${{ secrets.MAILGUN_API_KEY}}" >> .env
echo "OVERALL_MAILING_LIST=${{ secrets.OVERALL_MAILING_LIST}}" >> .env
echo "BOT_TOKEN=${{ secrets.BOT_TOKEN}}" >> .env
echo "USERNAME_DB=${{ secrets.USERNAME_DB }}" >> .env
echo "PASSWORD=${{ secrets.PASSWORD }}" >> .env
echo "DBHOST=${{ secrets.HOST }}" >> .env
echo "PORT=${{ secrets.PORT }}" >> .env
echo "DATABASE=${{ secrets.DATABASE }}" >> .env
echo "TABLE=${{ secrets.TABLE }}" >> .env
echo "GRAPHQLPORT=${{ secrets.GRAPHQLPORT }}" >> .env
echo "DATABASE_URL=${{ secrets.DATABASE_URL }}" >> .env
./deploy.sh