-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (113 loc) · 3.32 KB
/
Copy pathmain.yml
File metadata and controls
144 lines (113 loc) · 3.32 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: Build and Deploy
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
permissions:
contents: read
packages: write
jobs:
test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
run: npm ci
- name: Complexity threshold
run: npm run lint:complexity
continue-on-error: true
- name: RFC threshold
run: npm run metrics:rfc
continue-on-error: true
- name: Run tests
run: npm test
- name: Run tests with coverage
run: npm run test:coverage
- name: Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./frontend/coverage/lcov.info
build:
runs-on: ubuntu-latest
needs: test
defaults:
run:
working-directory: frontend
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image for CI
working-directory: .
run: docker build -t bitflow:test .
- name: Login to GHCR
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push multi-arch image
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: docker/build-push-action@v4
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ghcr.io/bitflow-dhbw/bitflow:latest
cache-from: type=gha
cache-to: type=gha,mode=max
test-deploy:
runs-on: ubuntu-latest
needs:
- test
- build
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build test environment image
run: docker build -t bitflow:test .
- name: Start app in test environment
run: docker run --detach --rm --name bitflow-test -p 8080:80 bitflow:test
- name: Check app health
run: |
for attempt in {1..30}; do
if curl --fail --silent --show-error http://localhost:8080/health; then
exit 0
fi
sleep 2
done
docker logs bitflow-test
exit 1
- name: Stop test environment
if: always()
run: docker stop bitflow-test
deploy:
runs-on: self-hosted
needs:
- test
- build
- test-deploy
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Pull new image
run: docker pull ghcr.io/bitflow-dhbw/bitflow:latest
- name: Restart container
run: |
docker compose -f /home/pi-5-server/BitFlow/docker-compose.yml down
docker compose -f /home/pi-5-server/BitFlow/docker-compose.yml up -d