Skip to content

Commit

Permalink
Opt build steps (#1238)
Browse files Browse the repository at this point in the history
* Add null value judgment

Signed-off-by: ZePan110 <[email protected]>
  • Loading branch information
ZePan110 authored Jan 27, 2025
1 parent f51f322 commit fda471e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-helm-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
Chart-test:
needs: [job1]
if: always() && ${{ needs.job1.outputs.run_matrix.service.length }} > 0
if: always() && ${{ fromJSON(needs.job1.outputs.run_matrix).length != 0 }}
uses: ./.github/workflows/_run-helm-chart.yml
strategy:
matrix: ${{ fromJSON(needs.job1.outputs.run_matrix) }}
Expand Down
22 changes: 15 additions & 7 deletions .github/workflows/push-image-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,28 @@ jobs:
- name: Get Test Services
id: get-services
run: |
set -x
base_commit=$(git rev-parse HEAD~1)
merged_commit=$(git log -1 --format='%H')
# git diff --name-only ${base_commit} ${merged_commit} | grep -E "cores|comps/__init__.py" | grep -Ev ".md"
# if [ $? -eq 0 ]; then
if git diff --name-only ${base_commit} ${merged_commit} | grep -E "cores|comps/__init__.py" | grep -Ev ".md"; then
echo "ALL image build!!!"
services=$(basename -a .github/workflows/docker/compose/*-compose.yaml | sed 's/-compose.yaml//' | jq -R '.' )
else
changed_src="$(git diff --name-only ${base_commit} ${merged_commit} | grep 'src/' | grep -vE '\.md')" || true
changed_yamls="$(git diff --name-only ${base_commit} ${merged_commit} | grep '.github/workflows/docker/compose/')" || true
services=$(printf '%s\n' "${changed_src[@]}" | cut -d'/' -f2 | grep -vE '\.py' | sort -u | jq -R '.' ) || true
while IFS= read -r line; do
filename=$(basename "$line" -compose.yaml)
echo "$line $(printf '%s\n' "$filename" | jq -R '.' )"
services+=" $(printf '%s\n' "$filename" | jq -R '.' )" || true
done <<< "$changed_yamls"
[[ -n "$changed_src" ]] && services=$(printf '%s\n' "${changed_src[@]}" | cut -d'/' -f2 | grep -vE '\.py' | sort -u | jq -R '.' ) || true
if [[ -n "$changed_yamls" ]]; then
while IFS= read -r line; do
filename=$(basename "$line" -compose.yaml)
echo "$line $(printf '%s\n' "$filename" | jq -R '.' )"
services+=" $(printf '%s\n' "$filename" | jq -R '.' )" || true
done <<< "$changed_yamls"
else
echo "No changes in YAML files."
fi
fi
echo "services=$(echo "$services" | jq -sc 'unique | sort')"
Expand All @@ -56,6 +62,7 @@ jobs:

image-build:
needs: get-build-matrix
if: ${{ fromJSON(needs.get-build-matrix.outputs.services).length != 0 }}
strategy:
matrix:
service: ${{ fromJSON(needs.get-build-matrix.outputs.services) }}
Expand All @@ -65,6 +72,7 @@ jobs:
steps:
- name: Clean up Working Directory
run: |
echo "matrix.service=${{ matrix.service }}"
sudo rm -rf ${{github.workspace}}/*
- name: Checkout out Repo
Expand Down

0 comments on commit fda471e

Please sign in to comment.