File tree Expand file tree Collapse file tree 2 files changed +75
-0
lines changed
Expand file tree Collapse file tree 2 files changed +75
-0
lines changed Original file line number Diff line number Diff line change 1+ name : CI Pipeline
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ workflow_dispatch :
8+ jobs :
9+ build :
10+ name : Build
11+ runs-on : ubuntu-latest
12+ outputs :
13+ version : ${{ steps.set_version.outputs.version }}
14+ services :
15+ mysql :
16+ image : mysql:8.0.29
17+ env :
18+ MYSQL_ROOT_PASSWORD : tempdbpassword
19+ MYSQL_DATABASE : pizza
20+ ports :
21+ - ' 3306:3306'
22+ options : >-
23+ --health-cmd "mysqladmin ping -ptempdbpassword" --health-interval 10s --health-start-period 10s --health-timeout 5s --health-retries 10
24+
25+
26+ steps :
27+ - name : Checkout repo
28+ uses : actions/checkout@v4
29+
30+ - name : Setup Node
31+ uses : actions/setup-node@v4
32+ with :
33+ node-version : ' 22.x'
34+
35+ - name : Install dependencies
36+ run : npm ci
37+
38+ - name : Lint
39+ run : npm run lint
40+
41+ - name : Write config file
42+ run : |
43+ echo "module.exports = {
44+ jwtSecret: '${{ secrets.JWT_SECRET }}',
45+ db: {
46+ connection: {
47+ host: '127.0.0.1',
48+ user: 'root',
49+ password: 'tempdbpassword',
50+ database: 'pizza',
51+ connectTimeout: 60000,
52+ },
53+ listPerPage: 10,
54+ },
55+ factory: {
56+ url: 'https://pizza-factory.cs329.click',
57+ apiKey: '${{ secrets.FACTORY_API_KEY }}',
58+ },
59+ };" > src/config.js
60+
61+ - name : Tests
62+ run : npm test
63+
64+ - name : set version
65+ id : set_version
66+ run : |
67+ version=$(date +'%Y%m%d.%H%M%S')
68+ echo "version=$version" >> "$GITHUB_OUTPUT"
69+ printf '{"version": "%s" }' "$version" > src/version.json
70+
71+ - name : Update coverage
72+ run : |
73+ coverage=$(jq '.total.lines.pct' coverage/coverage-summary.json)
74+ color=$(echo "$coverage < 80" | bc | awk '{if ($1) print "red"; else print "green"}')
75+ curl -s -X POST "https://pizza-factory.cs329.click/api/badge/${{ secrets.NET_ID }}/jwtpizzaservicecoverage?label=Coverage&value=$coverage%25&color=$color" -H "authorization: bearer ${{ secrets.FACTORY_API_KEY }}"
You can’t perform that action at this time.
0 commit comments