Skip to content
Merged

f #15

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"overrideCommand": true,
"runServices": ["db", "web"],
"remoteUser": "node",
"mounts": [
"source=${localEnv:SSH_AUTH_SOCK},target=/ssh-agent,type=bind"
],
"remoteEnv": { "VSCODE_AGENT_FOLDER": "/home/node/.vscode-server" },
"runArgs": ["--memory=6g", "--shm-size=1g"],

Expand Down
36 changes: 27 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ concurrency:
jobs:
build:
runs-on: ubuntu-latest
env:
NEXT_TELEMETRY_DISABLED: '1'
DATABASE_URL: postgresql://recipe:recipe@localhost:5432/recipebook

services:
postgres:
Expand All @@ -34,26 +37,29 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

# pnpm first (your approach), then Node (for cache)
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10.15.0
run_install: false

- name: Use Node 20
- name: Use Node 20 (with pnpm cache)
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm' # cache only; does NOT install pnpm
cache: 'pnpm' # cache only; pnpm is already installed above

- name: Install Postgres client
run: sudo apt-get update && sudo apt-get install -y postgresql-client

- name: Install deps
run: pnpm install --frozen-lockfile=false

- name: Prisma generate
run: pnpm exec prisma generate
- name: Prisma validate & generate
run: |
pnpm exec prisma validate
pnpm exec prisma generate

- name: Wait for DB
run: |
Expand All @@ -66,17 +72,29 @@ jobs:
echo "DB not ready" && exit 1

- name: Migrate + seed
env:
DATABASE_URL: postgresql://recipe:recipe@localhost:5432/recipebook
run: |
pnpm exec prisma migrate deploy
pnpm run seed || true

# Cache Next.js build cache to speed up subsequent builds
- name: Restore Next.js cache
uses: actions/cache@v4
with:
path: .next/cache
key: nextcache-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}-${{ hashFiles('next.config.*','src/**/*.[jt]s','src/**/*.[jt]sx') }}
restore-keys: |
nextcache-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}-

- name: Typecheck
run: pnpm exec tsc --noEmit

- name: Build
env:
NEXT_TELEMETRY_DISABLED: '1'
DATABASE_URL: postgresql://recipe:recipe@localhost:5432/recipebook
run: pnpm run build

- name: Save Next.js cache
if: always()
uses: actions/cache@v4
with:
path: .next/cache
key: nextcache-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.sha }}

25 changes: 21 additions & 4 deletions prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,21 @@
async function main(){
const book = await db.book.upsert({
where: { slug: 'winners' },
update: {},
create: { slug: 'winners', title: 'Tested Winners' },
update: {}

Check failure on line 9 in prisma/seed.ts

View workflow job for this annotation

GitHub Actions / build

An object literal cannot have multiple properties with the same name.
});

await db.recipe.create({
data: {
await db.recipe.upsert({
where: {
bookId_slug_version: {
bookId: book.id,
slug: 'carnitas-confit',
version: 1,
},
},
update: {}, // nothing to change if exists
create: {
bookId: book.id, slug: 'garlic-mojo', kind: 'COMPONENT',
title: 'Garlic Mojo', description: 'Citrusy garlicky oil for drizzling.',
status: 'PUBLISHED', version: 1,
Expand All @@ -27,8 +36,16 @@
}
});

await db.recipe.create({
data: {
await db.recipe.upsert({
where: {
bookId_slug_version: {
bookId: book.id,
slug: 'carnitas-confit',
version: 1,
},
},
update: {}, // nothing to change if exists
create: {
bookId: book.id, slug: 'carnitas-confit', kind: 'TOP_LEVEL',
title: 'Confit-Style Carnitas',
description: 'Pork shoulder gently confited in lard, then broiled crisp.',
Expand Down
Loading