GitHub Actions Integration
Overview
The official NexusDB GitHub Action lets you run migrations, seed data, and verify backups as part of your CI/CD workflow.
Setup
# .github/workflows/deploy.yml
name: Deploy
on:
push:
branches: [main]
jobs:
migrate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: nexusdb/action@v2
with:
connection: ${{ secrets.NEXUSDB_URL }}
api-key: ${{ secrets.NEXUSDB_API_KEY }}
command: migrate
migrations-dir: ./migrationsSchema Migrations
Create migration files in your repository:
migrations/
001_create_users.js
002_add_email_index.js
003_create_orders.jsEach migration exports up and down functions:
// migrations/001_create_users.js
exports.up = async (db) => {
await db.createCollection("users", {
fields: [
{ name: "email", type: "string", unique: true },
{ name: "name", type: "string" },
{ name: "created_at", type: "datetime", auto: true }
]
});
};
exports.down = async (db) => {
await db.dropCollection("users");
};Data Seeding
- uses: nexusdb/action@v2
with:
connection: ${{ secrets.NEXUSDB_URL }}
command: seed
seed-file: ./seeds/test-data.jsonBackup Verification
- uses: nexusdb/action@v2
with:
connection: ${{ secrets.NEXUSDB_URL }}
command: backup-verify
backup-bucket: s3://nexusdb-backups
max-age: 24hFull Deployment Pipeline
jobs:
test:
runs-on: ubuntu-latest
services:
nexusdb:
image: nexusdb/server:3.2
ports: ["4200:4200"]
steps:
- uses: actions/checkout@v4
- run: npm test
env:
NEXUSDB_URL: http://localhost:4200
deploy:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: nexusdb/action@v2
with:
connection: ${{ secrets.NEXUSDB_URL }}
command: migrate
- run: ./deploy.sh