Skip to content

Commit 0bb0abb

Browse files
authored
Fix issue (#826)
Signed-off-by: ZePan110 <ze.pan@intel.com>
1 parent e0b3b57 commit 0bb0abb

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

.github/workflows/pr-path-detection.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,17 @@ jobs:
9494
run: |
9595
cd ${{github.workspace}}
9696
fail="FALSE"
97-
link_head="https://github.com/opea-project/GenAIExamples/blob/main/"
97+
branch="https://github.com/opea-project/GenAIExamples/blob/${{ github.event.pull_request.head.ref }}"
98+
link_head="https://github.com/opea-project/GenAIExamples/blob/main"
9899
png_lines=$(grep -Eo '\]\([^)]+\)' -r -I .|grep -Ev 'http')
99100
if [ -n "$png_lines" ]; then
100101
for png_line in $png_lines; do
101102
refer_path=$(echo "$png_line"|cut -d':' -f1 | cut -d'/' -f2-)
102103
png_path=$(echo "$png_line"|cut -d '(' -f2 | cut -d ')' -f1)
103104
if [[ "${png_path:0:1}" == "/" ]]; then
104105
check_path=${{github.workspace}}$png_path
106+
elif [[ "${png_path:0:1}" == "#" ]]; then
107+
check_path=${{github.workspace}}/$refer_path$png_path
105108
else
106109
check_path=${{github.workspace}}/$(dirname "$refer_path")/$png_path
107110
fi
@@ -110,16 +113,29 @@ jobs:
110113
echo "Path $png_path in file ${{github.workspace}}/$refer_path does not exist"
111114
fail="TRUE"
112115
else
113-
url=$link_head$(echo "$real_path" | sed 's|.*/GenAIExamples/||')
116+
url=$link_head$(echo "$real_path" | sed 's|.*/GenAIExamples||')
114117
response=$(curl -I -L -s -o /dev/null -w "%{http_code}" "$url")
115118
if [ "$response" -ne 200 ]; then
116119
echo "**********Validation failed, try again**********"
117120
response_retry=$(curl -s -o /dev/null -w "%{http_code}" "$url")
118121
if [ "$response_retry" -eq 200 ]; then
119122
echo "*****Retry successfully*****"
120123
else
121-
echo "Invalid link from $check_path: $url"
122-
fail="TRUE"
124+
echo "Retry failed. Check branch ${{ github.event.pull_request.head.ref }}"
125+
url_dev=$branch$(echo "$real_path" | sed 's|.*/GenAIExamples||')
126+
response=$(curl -I -L -s -o /dev/null -w "%{http_code}" "$url_dev")
127+
if [ "$response" -ne 200 ]; then
128+
echo "**********Validation failed, try again**********"
129+
response_retry=$(curl -s -o /dev/null -w "%{http_code}" "$url_dev")
130+
if [ "$response_retry" -eq 200 ]; then
131+
echo "*****Retry successfully*****"
132+
else
133+
echo "Invalid link from $real_path: $url_dev"
134+
fail="TRUE"
135+
fi
136+
else
137+
echo "Check branch ${{ github.event.pull_request.head.ref }} successfully."
138+
fi
123139
fi
124140
fi
125141
fi

0 commit comments

Comments
 (0)