forked from LightningDotSpace/api
-
Notifications
You must be signed in to change notification settings - Fork 0
40 lines (36 loc) · 1.22 KB
/
Copy pathapi-migration-check.yaml
File metadata and controls
40 lines (36 loc) · 1.22 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
name: API Migration Check
on:
pull_request:
branches:
- main
- develop
paths:
- 'migration/**'
# The seed script and its data are actively maintained, not immutable schema migrations.
- '!migration/seed/**'
permissions:
contents: read
jobs:
immutability:
name: Migration immutability
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Block changes to existing migrations
run: |
git fetch origin ${{ github.base_ref }} --depth=100
# Protect immutable schema migrations only; the seed script/data may change freely.
CHANGED=$(git diff --name-status origin/${{ github.base_ref }}...HEAD -- migration/ ':(exclude)migration/seed/' \
| awk '$1 ~ /^[MDR]/ {print}')
if [ -n "$CHANGED" ]; then
echo "::error::Existing migrations must not be modified, renamed or deleted."
echo ""
echo "$CHANGED"
echo ""
echo "If a migration is wrong, add a follow-up migration instead of editing the old one."
exit 1
fi
echo "No existing migrations were modified."