@@ -94,14 +94,17 @@ jobs:
94
94
run : |
95
95
cd ${{github.workspace}}
96
96
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"
98
99
png_lines=$(grep -Eo '\]\([^)]+\)' -r -I .|grep -Ev 'http')
99
100
if [ -n "$png_lines" ]; then
100
101
for png_line in $png_lines; do
101
102
refer_path=$(echo "$png_line"|cut -d':' -f1 | cut -d'/' -f2-)
102
103
png_path=$(echo "$png_line"|cut -d '(' -f2 | cut -d ')' -f1)
103
104
if [[ "${png_path:0:1}" == "/" ]]; then
104
105
check_path=${{github.workspace}}$png_path
106
+ elif [[ "${png_path:0:1}" == "#" ]]; then
107
+ check_path=${{github.workspace}}/$refer_path$png_path
105
108
else
106
109
check_path=${{github.workspace}}/$(dirname "$refer_path")/$png_path
107
110
fi
@@ -110,16 +113,29 @@ jobs:
110
113
echo "Path $png_path in file ${{github.workspace}}/$refer_path does not exist"
111
114
fail="TRUE"
112
115
else
113
- url=$link_head$(echo "$real_path" | sed 's|.*/GenAIExamples/ ||')
116
+ url=$link_head$(echo "$real_path" | sed 's|.*/GenAIExamples||')
114
117
response=$(curl -I -L -s -o /dev/null -w "%{http_code}" "$url")
115
118
if [ "$response" -ne 200 ]; then
116
119
echo "**********Validation failed, try again**********"
117
120
response_retry=$(curl -s -o /dev/null -w "%{http_code}" "$url")
118
121
if [ "$response_retry" -eq 200 ]; then
119
122
echo "*****Retry successfully*****"
120
123
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
123
139
fi
124
140
fi
125
141
fi
0 commit comments