-
Notifications
You must be signed in to change notification settings - Fork 4
106 lines (100 loc) · 3.35 KB
/
ci.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
name: ci
on: [pull_request]
jobs:
# pylint:
# runs-on: ubuntu-latest
# if: "!contains(github.event.head_commit.message, '[ci skip]')"
# env:
# RUNNER_ALLOW_RUNASROOT: true
# steps:
# - uses: actions/checkout@v2
# - name: Fetch master
# run: git fetch origin master:refs/remotes/origin/master
# - name: Install pylint
# run: pip3 install pylint
# - name: List changed files
# run: |
# echo `git diff origin/master HEAD --name-only | grep .py` >> changed.txt
# - name: Check PEP8
# run: |
# while read file; do
# echo $file
# pylint $file
# done < changed.txt
#
format_python_code:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
ref: ${{ github.ref }}
- name: Blacken Python code
uses: jpetrucciani/black-check@master
with:
path: '.'
black_flags: '--safe --verbose --diff'
build:
#needs: pylint
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[ci skip]')"
env:
RUNNER_ALLOW_RUNASROOT: true
COCONNECT_DB_HOST: ${{ secrets.COCONNECT_DB_HOST }}
COCONNECT_DB_PORT: ${{ secrets.COCONNECT_DB_PORT }}
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Make envfile
run: |
touch .env
echo COCONNECT_DB_ENGINE=django.db.backends.postgresql >> .env
echo COCONNECT_DB_HOST=${{ secrets.COCONNECT_DB_HOST }} >> .env
echo COCONNECT_DB_NAME=${{ secrets.COCONNECT_DB_DB }} >> .env
echo COCONNECT_DB_PORT=${{ secrets.COCONNECT_DB_PORT }} >> .env
echo COCONNECT_DB_PASSWORD=${{ secrets.COCONNECT_DB_PASSWORD }} >> .env
echo COCONNECT_DB_USER=${{ secrets.COCONNECT_DB_USER }} >> .env
echo "SECRET_KEY=${{ secrets.SECRET_KEY }}" >> .env
echo DEBUG=True >> .env
echo ALLOWED_HOSTS=['localhost'] >> .env
- name: Build the docker image
run: docker build -f app/Dockerfile.deploy -t ccom-build:latest .
- name: Run the docker image
run: |
#startup the stack
docker run -it --env-file .env -p 8080:8000 -d ccom-build:latest
#give it 30s to start properly
sleep 30s
#get container ID
containerid=$(docker ps | awk 'NR==2' | awk '{print $1;}')
echo $containerid
#check the logs for errors
if docker logs $containerid | grep -i -q ERROR ; then
#print the errors before causing a fail
docker logs $containerid | grep -i ERROR
echo "Errors found"
exit 1
else
echo "No errors found!"
fi
echo "ended if"
#put the logs into a file
docker logs $containerid >> logs.out
#shutdown the container
docker stop $containerid
#save the logs so they can be further checked
- uses: actions/upload-artifact@v2
with:
name: my-artifact
path: logs.out
retention-days: 1
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Install dependencies and build Next.js app
run: |
npm install
npm run build
working-directory: app/next-client-app