Skip to content

Commit

Permalink
Add github workflow for analytics migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
jjnesbitt committed Aug 23, 2023
1 parent bc291d0 commit beee1f8
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/analytics_migrations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Check and Run Analytics Migrations

on:
pull_request:
paths:
- analytics/analytics
push:
paths:
- analytics/analytics/migrations
branches:
- main

jobs:
check-and-run-migrations:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

# If models have been changed and thus `makemigrations` must be run, this check fails
# This runs on pull requests and thus blocks until any necessary migrations have been created
- name: Check for Migrations
run: ./analytics/manage.py makemigrations --check --dry-run

# If changes pushed to analytics/analytics on main, run any necessary migrations
- name: Run Migrations
if: ${{ github.event_name == 'push' }}
run: ./analytics/manage.py migrate
env:
DB_HOST: ${{ secrets.ANALYTICS_DB_HOST }}
DB_NAME: ${{ secrets.ANALYTICS_DB_NAME }}
DB_USER: ${{ secrets.ANALYTICS_DB_USER }}
DB_PASS: ${{ secrets.ANALYTICS_DB_PASS }}

0 comments on commit beee1f8

Please sign in to comment.