96 lines
2.4 KiB
YAML
96 lines
2.4 KiB
YAML
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
|
|
|
|
jobs:
|
|
ci-gate:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout
|
|
run: |
|
|
git clone http://172.17.0.1:3000/kurihada/no-whatever.git .
|
|
git checkout ${{ github.sha }}
|
|
|
|
- name: Install Node.js
|
|
run: |
|
|
apt-get update -qq && apt-get install -y -qq nodejs npm
|
|
npm config set registry https://registry.npmmirror.com
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Generate Prisma
|
|
run: npx prisma generate
|
|
|
|
- name: Lint
|
|
run: npm run lint
|
|
|
|
- name: Unit tests
|
|
run: npm run test
|
|
|
|
build-and-deploy:
|
|
needs: ci-gate
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout
|
|
run: |
|
|
git clone http://172.17.0.1:3000/kurihada/no-whatever.git .
|
|
git checkout ${{ github.sha }}
|
|
|
|
- name: Build Docker image
|
|
run: |
|
|
docker build \
|
|
--build-arg NEXT_PUBLIC_AMAP_API_KEY="${{ secrets.AMAP_API_KEY }}" \
|
|
-t no-whatever:latest .
|
|
|
|
- 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
|
|
|
|
steps:
|
|
- name: Checkout
|
|
run: |
|
|
git clone http://172.17.0.1:3000/kurihada/no-whatever.git .
|
|
git checkout ${{ github.sha }}
|
|
|
|
- name: Install Node.js
|
|
run: |
|
|
apt-get update -qq && apt-get install -y -qq nodejs npm
|
|
npm config set registry https://registry.npmmirror.com
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Full E2E
|
|
run: |
|
|
npx prisma generate
|
|
npx playwright install chromium 2>/dev/null || true
|
|
npm run test:e2e
|