Skip to content

Commit

Permalink
Fix issue (#826)
Browse files Browse the repository at this point in the history
Signed-off-by: ZePan110 <ze.pan@intel.com>
  • Loading branch information
ZePan110 authored Sep 18, 2024
1 parent e0b3b57 commit 0bb0abb
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions .github/workflows/pr-path-detection.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,17 @@ jobs:
run: |
cd ${{github.workspace}}
fail="FALSE"
link_head="https://github.com/opea-project/GenAIExamples/blob/main/"
branch="https://github.com/opea-project/GenAIExamples/blob/${{ github.event.pull_request.head.ref }}"
link_head="https://github.com/opea-project/GenAIExamples/blob/main"
png_lines=$(grep -Eo '\]\([^)]+\)' -r -I .|grep -Ev 'http')
if [ -n "$png_lines" ]; then
for png_line in $png_lines; do
refer_path=$(echo "$png_line"|cut -d':' -f1 | cut -d'/' -f2-)
png_path=$(echo "$png_line"|cut -d '(' -f2 | cut -d ')' -f1)
if [[ "${png_path:0:1}" == "/" ]]; then
check_path=${{github.workspace}}$png_path
elif [[ "${png_path:0:1}" == "#" ]]; then
check_path=${{github.workspace}}/$refer_path$png_path
else
check_path=${{github.workspace}}/$(dirname "$refer_path")/$png_path
fi
Expand All @@ -110,16 +113,29 @@ jobs:
echo "Path $png_path in file ${{github.workspace}}/$refer_path does not exist"
fail="TRUE"
else
url=$link_head$(echo "$real_path" | sed 's|.*/GenAIExamples/||')
url=$link_head$(echo "$real_path" | sed 's|.*/GenAIExamples||')
response=$(curl -I -L -s -o /dev/null -w "%{http_code}" "$url")
if [ "$response" -ne 200 ]; then
echo "**********Validation failed, try again**********"
response_retry=$(curl -s -o /dev/null -w "%{http_code}" "$url")
if [ "$response_retry" -eq 200 ]; then
echo "*****Retry successfully*****"
else
echo "Invalid link from $check_path: $url"
fail="TRUE"
echo "Retry failed. Check branch ${{ github.event.pull_request.head.ref }}"
url_dev=$branch$(echo "$real_path" | sed 's|.*/GenAIExamples||')
response=$(curl -I -L -s -o /dev/null -w "%{http_code}" "$url_dev")
if [ "$response" -ne 200 ]; then
echo "**********Validation failed, try again**********"
response_retry=$(curl -s -o /dev/null -w "%{http_code}" "$url_dev")
if [ "$response_retry" -eq 200 ]; then
echo "*****Retry successfully*****"
else
echo "Invalid link from $real_path: $url_dev"
fail="TRUE"
fi
else
echo "Check branch ${{ github.event.pull_request.head.ref }} successfully."
fi
fi
fi
fi
Expand Down

0 comments on commit 0bb0abb

Please sign in to comment.