forked from opea-project/GenAIComps
-
Notifications
You must be signed in to change notification settings - Fork 0
117 lines (103 loc) · 3.94 KB
/
pr-dockerfile-path-scan.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
name: File Change Warning
on:
pull_request:
branches: [main]
types: [opened, reopened, ready_for_review, synchronize]
# If there is a new commit, the previous jobs will be canceled
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
Dockerfile-path-change-detection-in-GenAIComps:
runs-on: ubuntu-latest
steps:
- name: Clean Up Working Directory
run: sudo rm -rf ${{github.workspace}}/*
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for changed Dockerfile paths in yaml
run: |
set -xe
shopt -s globstar
cd ${{github.workspace}}
is_use="FALSE"
used_files=""
merged_commit=$(git log -1 --format='%H')
changed_files="$(git diff --name-status --diff-filter=DR ${{ github.event.pull_request.base.sha }} ${merged_commit} -- '**/Dockerfile**' | cut -f2)"
if [ -n "$changed_files" ]; then
for file in $changed_files; do
if grep -q "$file" .github/workflows/docker/compose/*.yaml; then
is_use="TRUE"
used_files+="$file "
fi
done
fi
if [[ "$is_use" == "TRUE" ]]; then
echo "Warning: Changed Dockerfile paths:"
echo "$used_files"
echo "Please modify the corresponding yaml in GenAIComps/.github/workflows/docker/compose and ask [email protected] for final confirmation."
exit 1
fi
- name: Check for changed Dockerfile paths in readme
run: |
set -xe
shopt -s globstar
cd ${{github.workspace}}
is_use="FALSE"
used_files=""
merged_commit=$(git log -1 --format='%H')
changed_files="$(git diff --name-status --diff-filter=DR ${{ github.event.pull_request.base.sha }} ${merged_commit} -- '**/Dockerfile**' | cut -f2)"
if [ -n "$changed_files" ]; then
for file in $changed_files; do
if grep -q "$file" ./**/*.md; then
is_use="TRUE"
used_files+="$file "
fi
done
fi
if [[ "$is_use" == "TRUE" ]]; then
echo "Warning: Changed Dockerfile paths:"
echo "$used_files"
echo "Please modify the corresponding README in GenAIComps and ask [email protected] for final confirmation."
exit 1
fi
Dockerfile-path-change-detection-in-GenAIExamples:
runs-on: ubuntu-latest
steps:
- name: Clean Up Working Directory
run: sudo rm -rf ${{github.workspace}}/*
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Clone repo GenAIExamples
run: |
cd ..
git clone https://github.com/opea-project/GenAIExamples
- name: Check for changed Dockerfile paths
run: |
set -xe
shopt -s globstar
cd ${{github.workspace}}
is_use="FALSE"
used_files=""
merged_commit=$(git log -1 --format='%H')
changed_files="$(git diff --name-status --diff-filter=DR ${{ github.event.pull_request.base.sha }} ${merged_commit} -- '**/Dockerfile' | cut -f2)"
if [ -n "$changed_files" ]; then
for file in $changed_files; do
if grep -q "$file" ../GenAIExamples/**/*.md; then
is_use="TRUE"
used_files+="$file "
fi
done
fi
if [[ "$is_use" == "TRUE" ]]; then
echo "Warning: Changed Dockerfile paths:"
echo "$used_files"
echo "Please modify the corresponding README in GenAIExamples repo and ask [email protected] for final confirmation."
exit 1
fi