Update deploy.yml

This commit is contained in:
Yonas Tewabe
2026-06-16 10:26:01 +03:00
committed by GitHub
parent d0689dfe04
commit ae967b324c

View File

@@ -32,15 +32,12 @@ jobs:
set -euo pipefail
ALL_SERVICES=(
"freight-api"
# "freight-portal"
# "freight-backoffice"
"passenger-api"
"passenger-portal"
"passenger-backoffice"
"payment-api"
)
# workflow_dispatch: deploy everything
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
JSON=$(printf '%s\n' "${ALL_SERVICES[@]}" | jq -R . | jq -sc .)
echo "matrix=${JSON}" >> "$GITHUB_OUTPUT"
@@ -54,53 +51,33 @@ jobs:
SERVICES=()
# -------------------------------------------------------
# Tier 1: Non-deployable files — skip if ONLY these changed
# -------------------------------------------------------
NON_DEPLOYABLE_PATTERN="^docs/|^README\.md$|^DEPLOYMENT\.md$|^CLAUDE\.md$|^checkpoint\.md$|^orgstructure\.md$|^ITMLS_DB_Design\.md$|.*\.md$|^\.eslintrc|^\.prettierrc|^\.editorconfig|^\.gitignore|^\.gitattributes|^commitlint\.config\.js$"
NON_DEPLOYABLE_PATTERN="^docs/|^README[.]md$|^DEPLOYMENT[.]md$|^CLAUDE[.]md$|^checkpoint[.]md$|^orgstructure[.]md$|^ITMLS_DB_Design[.]md$|.*[.]md$|^[.]eslintrc|^[.]prettierrc|^[.]editorconfig|^[.]gitignore|^[.]gitattributes|^commitlint[.]config[.]js$"
ALL_NON_DEPLOYABLE=true
while IFS= read -r file; do
if ! echo "$file" | grep -qE "$NON_DEPLOYABLE_PATTERN"; then
ALL_NON_DEPLOYABLE=false
break
fi
done <<< "$CHANGED"
GLOBAL_PATTERN="^[.]github/|^docker-compose[.]yaml$|^turbo[.]json$|^tsconfig[.]json$|^tsconfig[.]base[.]json$|^pnpm-workspace[.]yaml$|^pnpm-lock[.]yaml$|^package[.]json$|^[.]env([.][a-z]+)?$|^packages/|^infrastructure/|^scripts/deploy/|^wagon.*[.]ts$|^cargo.*[.]ts$|^container.*[.]ts$|^use-.*[.]ts$|^.*[.]service[.]ts$|^.*[.]entity[.]ts$|^.*-types[.]ts$"
if [ "$ALL_NON_DEPLOYABLE" = "true" ]; then
# Tier 1: skip if only non-deployable files changed
DEPLOYABLE=$(echo "$CHANGED" | grep -vE "$NON_DEPLOYABLE_PATTERN" || true)
if [ -z "$DEPLOYABLE" ]; then
echo "Only non-deployable files changed. Skipping deploy."
echo "matrix=[]" >> "$GITHUB_OUTPUT"
exit 0
fi
# -------------------------------------------------------
# Tier 2: Global files — deploy all services
# -------------------------------------------------------
GLOBAL_PATTERN="^[.]github/|^docker-compose\.yaml$|^turbo\.json$|^tsconfig\.json$|^tsconfig\.base\.json$|^pnpm-workspace\.yaml$|^pnpm-lock\.yaml$|^package\.json$|^[.]env([.][a-z]+)?$|^packages/|^infrastructure/|^scripts/deploy/|^wagon.*\.ts$|^cargo.*\.ts$|^container.*\.ts$|^use-.*\.ts$|^.*\.service\.ts$|^.*\.entity\.ts$|^.*-types\.ts$" if echo "$CHANGED" | grep -qE "$GLOBAL_PATTERN"; then
# Tier 2: deploy all if any global file changed
if echo "$CHANGED" | grep -qE "$GLOBAL_PATTERN"; then
echo "Global file(s) changed — deploying all services."
JSON=$(printf '%s\n' "${ALL_SERVICES[@]}" | jq -R . | jq -sc .)
echo "matrix=${JSON}" >> "$GITHUB_OUTPUT"
exit 0
fi
# -------------------------------------------------------
# Tier 3: Per-service app paths (exact structure)
# -------------------------------------------------------
# Freight
# Tier 3: per-service paths
echo "$CHANGED" | grep -q "^apps/edr-freight-api/" && SERVICES+=("freight-api")
# echo "$CHANGED" | grep -q "^apps/edr-freight-web/portal/" && SERVICES+=("freight-portal")
# echo "$CHANGED" | grep -q "^apps/edr-freight-web/backoffice/" && SERVICES+=("freight-backoffice")
# Passenger
echo "$CHANGED" | grep -q "^apps/edr-passenger-api/" && SERVICES+=("passenger-api")
echo "$CHANGED" | grep -q "^apps/edr-passenger-web/portal/" && SERVICES+=("passenger-portal")
echo "$CHANGED" | grep -q "^apps/edr-passenger-web/backoffice/" && SERVICES+=("passenger-backoffice")
# Payment
echo "$CHANGED" | grep -q "^apps/edr-payment-api/" && SERVICES+=("payment-api")
# Deduplicate while preserving consistent order
SERVICES=($(printf '%s\n' "${SERVICES[@]}" | sort -u))
if [ ${#SERVICES[@]} -eq 0 ]; then