forked from PinSpace-Org/GistPin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb-migration-runner.yml
More file actions
74 lines (64 loc) 路 2.06 KB
/
Copy pathdb-migration-runner.yml
File metadata and controls
74 lines (64 loc) 路 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: Database Migration Runner
on:
workflow_call:
inputs:
environment:
required: true
type: string
secrets:
DATABASE_URL:
required: true
workflow_dispatch:
inputs:
environment:
description: 'Target environment'
required: true
type: choice
options: [development, staging, production]
jobs:
migrate:
name: Run DB Migrations (${{ inputs.environment }})
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: Backend/package-lock.json
- name: Install dependencies
working-directory: Backend
run: npm ci
- name: Validate schema changes
run: bash infrastructure/scripts/run-migrations.sh validate
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
ENVIRONMENT: ${{ inputs.environment }}
- name: Run migrations
id: run_migrations
run: bash infrastructure/scripts/run-migrations.sh run
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
ENVIRONMENT: ${{ inputs.environment }}
- name: Generate migration report
if: always()
run: bash infrastructure/scripts/run-migrations.sh report
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
ENVIRONMENT: ${{ inputs.environment }}
- name: Rollback on failure
if: failure() && steps.run_migrations.outcome == 'failure'
run: bash infrastructure/scripts/rollback-migrations.sh
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
ENVIRONMENT: ${{ inputs.environment }}
- name: Upload migration report
if: always()
uses: actions/upload-artifact@v4
with:
name: migration-report-${{ inputs.environment }}-${{ github.sha }}
path: migration-report.json
retention-days: 30