ci: use env vars for input to scripts (#733)

This commit is contained in:
James Ward
2026-04-22 17:27:44 -04:00
committed by Zach Yale
parent f05feaea08
commit 2dbfe821a9
3 changed files with 32 additions and 18 deletions
+21 -12
View File
@@ -37,23 +37,26 @@ jobs:
- name: Normalize Diff Refs
id: normalize_refs
env:
BASE_REF: ${{ inputs.base_ref }}
HEAD_REF: ${{ inputs.head_ref }}
run: |
base_ref="${{ inputs.base_ref }}"
head_ref="${{ inputs.head_ref }}"
if [ "$base_ref" = "0000000000000000000000000000000000000000" ]; then
if [ "$BASE_REF" = "0000000000000000000000000000000000000000" ]; then
echo "base_ref is the all-zero sentinel; callers must supply a real comparison base for migration checks." >&2
exit 1
fi
echo "base_ref=$base_ref" >> "$GITHUB_OUTPUT"
echo "head_ref=$head_ref" >> "$GITHUB_OUTPUT"
echo "base_ref=$BASE_REF" >> "$GITHUB_OUTPUT"
echo "head_ref=$HEAD_REF" >> "$GITHUB_OUTPUT"
- name: Detect Flyway Migration Changes
id: check_migrations
env:
BASE_REF: ${{ steps.normalize_refs.outputs.base_ref }}
HEAD_REF: ${{ steps.normalize_refs.outputs.head_ref }}
run: |
echo "Comparing ${{ steps.normalize_refs.outputs.base_ref }}...${{ steps.normalize_refs.outputs.head_ref }}"
if git diff --name-only "${{ steps.normalize_refs.outputs.base_ref }}...${{ steps.normalize_refs.outputs.head_ref }}" | grep -Eq "^booklore-api/src/main/resources/db/migration/V.*\\.sql$"; then
echo "Comparing ${BASE_REF}...${HEAD_REF}"
if git diff --name-only "${BASE_REF}...${HEAD_REF}" | grep -Eq "^booklore-api/src/main/resources/db/migration/V.*\\.sql$"; then
echo "Migration file changes detected. Proceeding with migration preview."
echo "has_migrations=true" >> "$GITHUB_OUTPUT"
else
@@ -88,10 +91,13 @@ jobs:
fetch-depth: 0
- name: Apply Migrations from Base Branch
env:
GITHUB_WORKSPACE: ${{ github.workspace }}
BASE_REF: ${{ needs.check-for-migrations.outputs.base_ref }}
run: |
echo "Applying migrations from base ref (${{ needs.check-for-migrations.outputs.base_ref }})..."
echo "Applying migrations from base ref (${BASE_REF})..."
docker run --network host \
-v ${{ github.workspace }}:/flyway/sql \
-v ${GITHUB_WORKSPACE}:/flyway/sql \
flyway/flyway:12.1.0 \
-url=jdbc:mariadb://127.0.0.1:3306/booklore_test \
-user=root -password=root \
@@ -105,10 +111,13 @@ jobs:
fetch-depth: 0
- name: Apply Migrations from Head Branch
env:
GITHUB_WORKSPACE: ${{ github.workspace }}
HEAD_REF: ${{ needs.check-for-migrations.outputs.head_ref }}
run: |
echo "Applying new migrations from head ref (${{ needs.check-for-migrations.outputs.head_ref }})..."
echo "Applying new migrations from head ref (${HEAD_REF})..."
docker run --network host \
-v ${{ github.workspace }}:/flyway/sql \
-v ${GITHUB_WORKSPACE}:/flyway/sql \
flyway/flyway:12.1.0 \
-url=jdbc:mariadb://127.0.0.1:3306/booklore_test \
-user=root -password=root \