Skip to content

Commit

Permalink
Add GitHub workflows for database migrations and configure Dependabot
Browse files Browse the repository at this point in the history
  • Loading branch information
Perdolique committed Dec 9, 2024
1 parent fd2f060 commit 1e26997
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 1 deletion.
17 changes: 17 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "npm"
directory: "/" # Location of package manifests
schedule:
interval: "daily"
groups:
all-updates:
applies-to: version-updates
patterns:
- "*"

27 changes: 27 additions & 0 deletions .github/workflows/database-migration-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Database migration (production)

on:
push:
branches:
- master
paths:
- 'migrations/**'

jobs:
migration:
runs-on: ubuntu-24.04
environment: production
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22.12.0'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run database migration
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
run: npm run db:migrate
31 changes: 31 additions & 0 deletions .github/workflows/database-migration-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Database migration (staging)

on:
pull_request:
branches:
- master
paths:
- 'migrations/**'

jobs:
migration:
runs-on: ubuntu-24.04
environment: staging
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22.12.0'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run database migration
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
run: npm run db:migrate
- name: Seed database
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
run: npm run db:seed
1 change: 1 addition & 0 deletions drizzle.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export default defineConfig({
schema: './src/lib/server/db/schema.ts',
verbose: true,
strict: true,
out: './migrations',

dbCredentials: {
url: process.env.DATABASE_URL
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"db:start": "docker compose up -d",
"db:push": "drizzle-kit push",
"db:migrate": "drizzle-kit migrate",
"db:studio": "drizzle-kit studio"
"db:studio": "drizzle-kit studio",
"db:seed": "exit 0"
},
"devDependencies": {
"@sveltejs/adapter-cloudflare": "4.8.0",
Expand Down

0 comments on commit 1e26997

Please sign in to comment.