Add Gitea Actions workflow (migrated from Jenkins)
This commit is contained in:
@@ -0,0 +1,121 @@
|
|||||||
|
name: CI and Deploy
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
run_full_e2e:
|
||||||
|
description: 'Run full E2E tests after deploy'
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
run_coverage:
|
||||||
|
description: 'Run coverage tests'
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ci-gate:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: mcr.microsoft.com/playwright:v1.51.1-jammy
|
||||||
|
options: -v /var/run/docker.sock:/var/run/docker.sock --ipc=host
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '20'
|
||||||
|
|
||||||
|
- name: Cache npm
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ~/.npm
|
||||||
|
key: npm-${{ hashFiles('package-lock.json') }}
|
||||||
|
restore-keys: npm-
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
- name: Generate Prisma client
|
||||||
|
run: npx prisma generate
|
||||||
|
|
||||||
|
- name: Lint
|
||||||
|
run: npm run lint
|
||||||
|
|
||||||
|
- name: Unit tests
|
||||||
|
run: |
|
||||||
|
if [ "${{ inputs.run_coverage }}" = "true" ]; then
|
||||||
|
npm run test:coverage
|
||||||
|
else
|
||||||
|
npm run test
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Smoke E2E tests
|
||||||
|
run: |
|
||||||
|
npx playwright install chromium
|
||||||
|
npm run test:e2e:smoke
|
||||||
|
|
||||||
|
build-and-deploy:
|
||||||
|
needs: ci-gate
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
options: -v /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Build Docker image
|
||||||
|
run: |
|
||||||
|
docker build \
|
||||||
|
--build-arg NEXT_PUBLIC_AMAP_API_KEY="${{ secrets.AMAP_API_KEY }}" \
|
||||||
|
-t no-whatever:latest \
|
||||||
|
-t no-whatever:${{ github.sha }} \
|
||||||
|
.
|
||||||
|
|
||||||
|
- name: Deploy
|
||||||
|
run: |
|
||||||
|
docker stop no-whatever || true
|
||||||
|
docker rm no-whatever || true
|
||||||
|
mkdir -p /data/no-whatever
|
||||||
|
chown 1001:1001 /data/no-whatever
|
||||||
|
docker run -d \
|
||||||
|
--name no-whatever \
|
||||||
|
--network nginx \
|
||||||
|
-p 3721:3721 \
|
||||||
|
-v /data/no-whatever:/app/data \
|
||||||
|
-e DATABASE_URL=file:/app/data/prod.db \
|
||||||
|
-e AMAP_API_KEY="${{ secrets.AMAP_API_KEY }}" \
|
||||||
|
-e DEEPSEEK_API_KEY="${{ secrets.DEEPSEEK_API_KEY }}" \
|
||||||
|
--restart unless-stopped \
|
||||||
|
no-whatever:latest
|
||||||
|
|
||||||
|
full-e2e:
|
||||||
|
needs: build-and-deploy
|
||||||
|
if: ${{ inputs.run_full_e2e }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: mcr.microsoft.com/playwright:v1.51.1-jammy
|
||||||
|
options: --ipc=host
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '20'
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
- name: Full E2E tests
|
||||||
|
run: |
|
||||||
|
npx prisma generate
|
||||||
|
npx playwright install chromium
|
||||||
|
npm run test:e2e
|
||||||
Reference in New Issue
Block a user