Skip to content

Commit 4932846

Browse files
committed
fix(ci): build all services when workflow changes
- Add logic to detect workflow file modifications - Build all services when workflow itself is updated - Prevents skipped builds when only CI config changes
1 parent edc6a41 commit 4932846

File tree

2 files changed

+29
-17
lines changed

2 files changed

+29
-17
lines changed

.github/workflows/build-push-images.yml

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ devenv.local.nix
3030
# direnv
3131
.direnv
3232

33-
.pre-commit-config.yaml
33+
.pre-commit-config.yamltemp/

0 commit comments

Comments
 (0)