Skip to content

Commit

Permalink
Skip subsequent steps if there are no schema changes
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyMcCormick committed Dec 10, 2024
1 parent 5885482 commit 202eb02
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/compare.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,24 @@ jobs:
run: |
echo "Checking for changes compared with: ${{ github.event.pull_request.base.ref }}"
CHANGED_FILES=$(git diff --name-only origin/${{ github.event.pull_request.base.ref }}..HEAD -- ${{ env.SCHEMA_DIR }} | grep '\.yaml$')
CHANGED_FILES=$(echo "$CHANGED_FILES" | sed "s|^${{ env.SCHEMA_DIR }}/||" | tr '\n' ' ')
echo "CHANGED_FILES=$CHANGED_FILES" >> $GITHUB_ENV
if [ -z "$CHANGED_FILES" ]; then
echo "No schema files changed."
echo "schema_files_changed=false" >> $GITHUB_ENV
else
CHANGED_FILES=$(echo "$CHANGED_FILES" | sed "s|^${{ env.SCHEMA_DIR }}/||" | tr '\n' ' ')
echo "CHANGED_FILES=$CHANGED_FILES" >> $GITHUB_ENV
echo "schema_files_changed=true" >> $GITHUB_ENV
fi
- name: Check out PR base ref
if: env.schema_files_changed == 'true'
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.ref }}
path: base-ref

- name: Run deepdiff comparison
if: env.schema_files_changed == 'true'
run: |
for file in ${{ env.CHANGED_FILES }}; do
echo "Comparing $file..."
Expand All @@ -54,6 +62,7 @@ jobs:
done
- name: Run alembic comparison
if: env.schema_files_changed == 'true'
run: |
for file in ${{ env.CHANGED_FILES }}; do
echo "Comparing $file..."
Expand All @@ -63,6 +72,7 @@ jobs:
done
- name: Run alembic comparison on deployed schemas
if: env.schema_files_changed == 'true'
run: |
ERROR_FLAG=0
DEPLOYED_SCHEMAS=$(cat current-ref/yml/deployed-schemas.txt)
Expand Down

0 comments on commit 202eb02

Please sign in to comment.