Skip to content

Merge branch 'main' of https://github.com/iftt-jonathan/jwt-pizza-ser… #5

Merge branch 'main' of https://github.com/iftt-jonathan/jwt-pizza-ser…

Merge branch 'main' of https://github.com/iftt-jonathan/jwt-pizza-ser… #5

Workflow file for this run

name: CI Pipeline
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
name: Build
runs-on: ubuntu-latest
outputs:
version: ${{ steps.set_version.outputs.version }}
services:
mysql:
image: mysql:8.0.29
env:
MYSQL_ROOT_PASSWORD: tempdbpassword
MYSQL_DATABASE: pizza
ports:
- "3306:3306"
options: >-
--health-cmd "mysqladmin ping -ptempdbpassword"
--health-interval 10s
--health-start-period 10s
--health-timeout 5s
--health-retries 10
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20.x"
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
- name: Write config file
run: |
echo "module.exports = {
jwtSecret: '${{ secrets.JWT_SECRET }}',
db: {
connection: {
host: '127.0.0.1',
user: 'root',
password: 'tempdbpassword',
database: 'pizza',
connectTimeout: 60000,
},
listPerPage: 10,
},
factory: {
url: 'https://pizza-factory.cs329.click',
apiKey: '${{ secrets.FACTORY_API_KEY }}',
},
};" > src/config.js
- name: Tests
run: npm test
- name: set version
id: set_version
run: |
version=$(date +'%Y%m%d.%H%M%S')
echo "version=$version" >> "$GITHUB_OUTPUT"
printf '{"version": "%s" }' "$version" > src/version.json
- name: Update coverage
run: |
coverage_pct=$(grep -o '"pct":[0-9.]*' coverage/coverage-summary.json | head -n 1 | cut -d ':' -f 2)
color=$(echo "$coverage_pct < 80" | bc -l | awk '{if ($1) print "yellow"; else print "green"}')
curl https://img.shields.io/badge/Coverage-$coverage_pct%25-$color -o coverageBadge.svg
git config user.name github-actions
git config user.email github-actions@github.com
git add .
git commit -m "generated"
git push