Skip to content

Commit fda471e

Browse files
authored
Opt build steps (#1238)
* Add null value judgment Signed-off-by: ZePan110 <ze.pan@intel.com>
1 parent f51f322 commit fda471e

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

.github/workflows/pr-helm-test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
6464
Chart-test:
6565
needs: [job1]
66-
if: always() && ${{ needs.job1.outputs.run_matrix.service.length }} > 0
66+
if: always() && ${{ fromJSON(needs.job1.outputs.run_matrix).length != 0 }}
6767
uses: ./.github/workflows/_run-helm-chart.yml
6868
strategy:
6969
matrix: ${{ fromJSON(needs.job1.outputs.run_matrix) }}

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

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,28 @@ jobs:
3232
- name: Get Test Services
3333
id: get-services
3434
run: |
35+
set -x
3536
base_commit=$(git rev-parse HEAD~1)
3637
merged_commit=$(git log -1 --format='%H')
3738
# git diff --name-only ${base_commit} ${merged_commit} | grep -E "cores|comps/__init__.py" | grep -Ev ".md"
38-
# if [ $? -eq 0 ]; then
39+
3940
if git diff --name-only ${base_commit} ${merged_commit} | grep -E "cores|comps/__init__.py" | grep -Ev ".md"; then
4041
echo "ALL image build!!!"
4142
services=$(basename -a .github/workflows/docker/compose/*-compose.yaml | sed 's/-compose.yaml//' | jq -R '.' )
4243
else
4344
changed_src="$(git diff --name-only ${base_commit} ${merged_commit} | grep 'src/' | grep -vE '\.md')" || true
4445
changed_yamls="$(git diff --name-only ${base_commit} ${merged_commit} | grep '.github/workflows/docker/compose/')" || true
45-
services=$(printf '%s\n' "${changed_src[@]}" | cut -d'/' -f2 | grep -vE '\.py' | sort -u | jq -R '.' ) || true
46-
while IFS= read -r line; do
47-
filename=$(basename "$line" -compose.yaml)
48-
echo "$line $(printf '%s\n' "$filename" | jq -R '.' )"
49-
services+=" $(printf '%s\n' "$filename" | jq -R '.' )" || true
50-
done <<< "$changed_yamls"
46+
[[ -n "$changed_src" ]] && services=$(printf '%s\n' "${changed_src[@]}" | cut -d'/' -f2 | grep -vE '\.py' | sort -u | jq -R '.' ) || true
47+
48+
if [[ -n "$changed_yamls" ]]; then
49+
while IFS= read -r line; do
50+
filename=$(basename "$line" -compose.yaml)
51+
echo "$line $(printf '%s\n' "$filename" | jq -R '.' )"
52+
services+=" $(printf '%s\n' "$filename" | jq -R '.' )" || true
53+
done <<< "$changed_yamls"
54+
else
55+
echo "No changes in YAML files."
56+
fi
5157
fi
5258
5359
echo "services=$(echo "$services" | jq -sc 'unique | sort')"
@@ -56,6 +62,7 @@ jobs:
5662

5763
image-build:
5864
needs: get-build-matrix
65+
if: ${{ fromJSON(needs.get-build-matrix.outputs.services).length != 0 }}
5966
strategy:
6067
matrix:
6168
service: ${{ fromJSON(needs.get-build-matrix.outputs.services) }}
@@ -65,6 +72,7 @@ jobs:
6572
steps:
6673
- name: Clean up Working Directory
6774
run: |
75+
echo "matrix.service=${{ matrix.service }}"
6876
sudo rm -rf ${{github.workspace}}/*
6977
7078
- name: Checkout out Repo

0 commit comments

Comments
 (0)