@@ -60,28 +60,40 @@ jobs:
6060 elif [ "${{ github.event_name }}" == "pull_request" ]; then
6161 # For PRs, check which services changed
6262 CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }})
63- SERVICES=""
64- for service in ui catalog cart orders checkout; do
65- if echo "$CHANGED_FILES" | grep -q "^src/$service/"; then
66- SERVICES="${SERVICES}${service},"
63+
64+ # If workflow file changed, build all services
65+ if echo "$CHANGED_FILES" | grep -q "^.github/workflows/build-push-images.yml"; then
66+ SERVICES="ui,catalog,cart,orders,checkout"
67+ else
68+ SERVICES=""
69+ for service in ui catalog cart orders checkout; do
70+ if echo "$CHANGED_FILES" | grep -q "^src/$service/"; then
71+ SERVICES="${SERVICES}${service},"
72+ fi
73+ done
74+ SERVICES=${SERVICES%,} # Remove trailing comma
75+ if [ -z "$SERVICES" ]; then
76+ SERVICES="none"
6777 fi
68- done
69- SERVICES=${SERVICES%,} # Remove trailing comma
70- if [ -z "$SERVICES" ]; then
71- SERVICES="none"
7278 fi
7379 else
7480 # For push to main, check which services changed
7581 CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }})
76- SERVICES=""
77- for service in ui catalog cart orders checkout; do
78- if echo "$CHANGED_FILES" | grep -q "^src/$service/"; then
79- SERVICES="${SERVICES}${service},"
82+
83+ # If workflow file changed, build all services
84+ if echo "$CHANGED_FILES" | grep -q "^.github/workflows/build-push-images.yml"; then
85+ SERVICES="ui,catalog,cart,orders,checkout"
86+ else
87+ SERVICES=""
88+ for service in ui catalog cart orders checkout; do
89+ if echo "$CHANGED_FILES" | grep -q "^src/$service/"; then
90+ SERVICES="${SERVICES}${service},"
91+ fi
92+ done
93+ SERVICES=${SERVICES%,} # Remove trailing comma
94+ if [ -z "$SERVICES" ]; then
95+ SERVICES="none"
8096 fi
81- done
82- SERVICES=${SERVICES%,} # Remove trailing comma
83- if [ -z "$SERVICES" ]; then
84- SERVICES="none"
8597 fi
8698 fi
8799 echo "services=$SERVICES" >> $GITHUB_OUTPUT
0 commit comments