Skip to content

Commit 8a11413

Browse files
authored
Optimize the content of the alerts. (#640)
Signed-off-by: ZePan110 <[email protected]> Signed-off-by: chensuyue <[email protected]>
1 parent 58e9972 commit 8a11413

File tree

1 file changed

+33
-32
lines changed

1 file changed

+33
-32
lines changed

.github/workflows/pr-dockerfile-path-scan.yaml

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ jobs:
5151
fi
5252
5353
- name: Check for changed Dockerfile paths in readme
54+
if: always()
5455
run: |
5556
set -e
5657
shopt -s globstar
@@ -75,6 +76,37 @@ jobs:
7576
exit 1
7677
fi
7778
79+
- name: Check new Dockerfile in compose yaml
80+
if: always()
81+
run: |
82+
set -xe
83+
shopt -s globstar
84+
cd ${{github.workspace}}
85+
no_add="FALSE"
86+
merged_commit=$(git log -1 --format='%H')
87+
changed_files="$(git diff --name-status --diff-filter=A ${{ github.event.pull_request.base.sha }} ${merged_commit} -- '**/Dockerfile**' | cut -f2)"
88+
changed_yamls="$(git diff --name-status --diff-filter=AM ${{ github.event.pull_request.base.sha }} ${merged_commit} -- '**/*.yaml**' | cut -f2)"
89+
if [ -n "$changed_files" ]; then
90+
for file in $changed_files; do
91+
service=$(echo "$file" | awk -F '/' '{print $2}')
92+
if find "${{github.workspace}}/.github/workflows/docker/compose/" -name "*$service*" |grep -q .; then
93+
if [ -n "$changed_files" ] && grep -q $service'-compose-cd.yaml' <<< "$changed_yamls"; then
94+
echo "The $file has been added to the ${{github.workspace}}/.github/workflows/docker/compose/"$service"-compose-cd.yaml."
95+
else
96+
echo "Please check if the added $file is included in the yaml under path ${{github.workspace}}/.github/workflows/docker/compose/"$service"-compose-cd.yaml."
97+
no_add="TRUE"
98+
fi
99+
else
100+
echo "Please create a new compose file named "$service"-compose-cd.yaml in ${{github.workspace}}/.github/workflows/docker/compose/ for $file and fill it in."
101+
no_add="TRUE"
102+
fi
103+
done
104+
fi
105+
106+
if [[ "$no_add" == "TRUE" ]]; then
107+
exit 1
108+
fi
109+
78110
Dockerfile-path-change-detection-in-GenAIExamples:
79111
runs-on: ubuntu-latest
80112
steps:
@@ -99,7 +131,7 @@ jobs:
99131
is_use="FALSE"
100132
used_files=""
101133
merged_commit=$(git log -1 --format='%H')
102-
changed_files="$(git diff --name-status --diff-filter=DR ${{ github.event.pull_request.base.sha }} ${merged_commit} -- '**/Dockerfile' | cut -f2)"
134+
changed_files="$(git diff --name-status --diff-filter=DR ${{ github.event.pull_request.base.sha }} ${merged_commit} -- '**/Dockerfile**' | cut -f2)"
103135
if [ -n "$changed_files" ]; then
104136
for file in $changed_files; do
105137
matching_files=$(grep -rl "$file" ../GenAIExamples/**/*.md)
@@ -118,34 +150,3 @@ jobs:
118150
echo "Please modify the corresponding README in GenAIExamples repo and ask [email protected] for final confirmation."
119151
exit 1
120152
fi
121-
122-
Dockerfile-addition-detection-in-GenAIComps:
123-
runs-on: ubuntu-latest
124-
steps:
125-
- name: Clean Up Working Directory
126-
run: sudo rm -rf ${{github.workspace}}/*
127-
128-
- name: Checkout code
129-
uses: actions/checkout@v4
130-
with:
131-
fetch-depth: 0
132-
133-
- name: Check if the Dockerfile has been added
134-
run: |
135-
set -e
136-
shopt -s globstar
137-
cd ${{github.workspace}}
138-
is_use="FALSE"
139-
used_files=""
140-
merged_commit=$(git log -1 --format='%H')
141-
changed_files="$(git diff --name-status --diff-filter=A ${{ github.event.pull_request.base.sha }} ${merged_commit} -- '**/Dockerfile**' | cut -f2)"
142-
if [ -n "$changed_files" ]; then
143-
for file in $changed_files; do
144-
if find "${{github.workspace}}/.github/workflows/docker/compose/" -name "*$(echo "$file" | awk -F '/' '{print $2}')*" |grep -q .; then
145-
echo "Please check if the added $file is included in the yaml under path ${{github.workspace}}/.github/workflows/docker/compose/."
146-
else
147-
echo "Please create a new compose file named service_name-compose-cd.yaml in ${{github.workspace}}/.github/workflows/docker/compose/ for $file and fill it in."
148-
fi
149-
done
150-
exit 1
151-
fi

0 commit comments

Comments
 (0)