-
Notifications
You must be signed in to change notification settings - Fork 4
43 lines (37 loc) · 1.29 KB
/
Build-check.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
name: check docker build
on:
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: copie .env file
run: |
cp .env.example .env
cp esp32/config/secrets.yaml.example esp32/config/secrets.yaml
- name: generate random jwt secret token
run: |
sed -i '/JWT_SECRET/d' .env
echo "JWT_SECRET=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 32)" >> .env
- name: generate random password for jwt token
run: |
sed -i '/POSTGRES_PASSWORD/d' .env
echo "POSTGRES_PASSWORD=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 32)" >> .env
- name: build and test
run: docker compose -f docker-compose.prod.yml up -d --remove-orphans --build
- name: test login with admin return token
run: |
sleep 10
export TOKEN=$(curl -X POST -H "Content-Type: application/json" -d '{"username": "admin", "password": "admin"}' http://localhost/php/login | jq ".token")
if [ "$TOKEN" == "null" ] || [ -z "$TOKEN" ]; then
echo "token is empty"
exit 1
fi