This commit is contained in:
+13
-88
@@ -1,94 +1,19 @@
|
|||||||
name: CI
|
name: Gitea Actions Demo
|
||||||
|
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
|
||||||
on:
|
on: [push]
|
||||||
pull_request:
|
|
||||||
branches: ['**']
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-test:
|
Explore-Gitea-Actions:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
services:
|
|
||||||
postgres:
|
|
||||||
image: postgres:16-alpine
|
|
||||||
env:
|
|
||||||
POSTGRES_USER: steakhouse
|
|
||||||
POSTGRES_PASSWORD: steakhouse
|
|
||||||
POSTGRES_DB: steakhouse
|
|
||||||
ports:
|
|
||||||
- 5432:5432
|
|
||||||
options: >-
|
|
||||||
--health-cmd "pg_isready -U steakhouse"
|
|
||||||
--health-interval 5s
|
|
||||||
--health-timeout 5s
|
|
||||||
--health-retries 10
|
|
||||||
|
|
||||||
env:
|
|
||||||
DATABASE_URL: postgres://steakhouse:steakhouse@localhost:5432/steakhouse
|
|
||||||
BETTER_AUTH_SECRET: ci-only-secret-not-used-in-production
|
|
||||||
BETTER_AUTH_URL: http://localhost:4173
|
|
||||||
STAFF_SEED_EMAIL: admin@example.com
|
|
||||||
STAFF_SEED_PASSWORD: ci-only-password-not-used-in-production
|
|
||||||
RESEND_API_KEY: re_ci_dummy_key
|
|
||||||
RESERVATIONS_FROM_EMAIL: 'Steakhaus bei Mirko <onboarding@resend.dev>'
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
|
||||||
|
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
|
||||||
|
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
|
||||||
|
- name: Check out repository code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
|
||||||
- name: Setup Node.js
|
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
|
||||||
uses: actions/setup-node@v4
|
- name: List files in the repository
|
||||||
with:
|
|
||||||
node-version: 22
|
|
||||||
cache: npm
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: npm ci
|
|
||||||
|
|
||||||
- name: Type check
|
|
||||||
run: npx tsc --noEmit
|
|
||||||
|
|
||||||
- name: Check that Drizzle migrations are up to date
|
|
||||||
run: |
|
run: |
|
||||||
npx drizzle-kit generate
|
ls ${{ gitea.workspace }}
|
||||||
if [ -n "$(git status --porcelain drizzle)" ]; then
|
- run: echo "🍏 This job's status is ${{ job.status }}."
|
||||||
echo "::error::src/db/schema.ts changed without a matching migration. Run 'npm run db:generate' and commit the result."
|
|
||||||
git status --porcelain drizzle
|
|
||||||
git diff drizzle
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Apply migrations
|
|
||||||
run: npm run db:migrate
|
|
||||||
|
|
||||||
- name: Seed baseline data
|
|
||||||
run: npm run db:seed
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
run: npm run build
|
|
||||||
|
|
||||||
- name: Smoke test the production build
|
|
||||||
run: |
|
|
||||||
npx vite preview --port 4173 &
|
|
||||||
PREVIEW_PID=$!
|
|
||||||
|
|
||||||
for i in $(seq 1 30); do
|
|
||||||
curl -sf http://localhost:4173/ >/dev/null 2>&1 && break
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
|
|
||||||
check() {
|
|
||||||
code=$(curl -s -o /dev/null -w '%{http_code}' "http://localhost:4173$1")
|
|
||||||
if [ "$code" != "$2" ]; then
|
|
||||||
echo "::error::GET $1 returned $code, expected $2"
|
|
||||||
kill "$PREVIEW_PID"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "GET $1 -> $code"
|
|
||||||
}
|
|
||||||
|
|
||||||
check / 200
|
|
||||||
check /staff/login 200
|
|
||||||
check /impressum 200
|
|
||||||
|
|
||||||
kill "$PREVIEW_PID"
|
|
||||||
Reference in New Issue
Block a user