Skip to content

Automate migrations #20

Automate migrations

Automate migrations #20

name: Apply staging migrations on PR when there are changes in the migrations folder
on:
pull_request:
types: [opened, synchronize]
jobs:
check-folder-changes:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check for changes in migrations folder
id: check_changes
run: |
git fetch origin main
git fetch origin ${{ github.head_ref || github.ref_name }}
git checkout ${{ github.head_ref || github.ref_name }}
if git diff --name-only origin/main...HEAD | grep -q '^migrations/'; then
echo "CHANGES=true" >> $GITHUB_ENV
else
echo "CHANGES=false" >> $GITHUB_ENV
fi
apply-staging:
needs: check-folder-changes
if: ${{ env.CHANGES == 'true' }}

Check failure on line 29 in .github/workflows/staging-migrations.yaml

View workflow run for this annotation

GitHub Actions / Apply staging migrations on PR when there are changes in the migrations folder

Invalid workflow file

The workflow is not valid. .github/workflows/staging-migrations.yaml (Line: 29, Col: 9): Unrecognized named-value: 'env'. Located at position 1 within expression: env.CHANGES == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install dependencies
run: npm install
- name: Run TypeScript script
run: npm run migrations:apply-staging