diff --git a/.github/workflows/preview-link.yml b/.github/workflows/preview-link.yml index ef49f24e3ea..4781a576547 100644 --- a/.github/workflows/preview-link.yml +++ b/.github/workflows/preview-link.yml @@ -98,23 +98,14 @@ jobs: CHANGED_FILES="${{ steps.files.outputs.changed_files }}" if [ -z "$CHANGED_FILES" ]; then - echo "No documentation files were changed." + echo "No changed files found in the specified directories." LINKS="- No documentation files were changed." else - LINKS="" - for FILE in $CHANGED_FILES; do - # Remove 'website/docs/' prefix and '.md' extension - FILE_PATH="${FILE#website/docs/}" - FILE_PATH="${FILE_PATH%.md}" - # Replace spaces and special characters with hyphens in URL path - URL_PATH=$(echo "$FILE_PATH" | sed 's/ /-/g; s/[^a-zA-Z0-9\-\/]//g' | tr '[:upper:]' '[:lower:]') - FULL_URL="$DEPLOYMENT_URL/$URL_PATH" - LINKS="$LINKS\n- [$FULL_URL]($FULL_URL)" - done + LINKS=$(echo "$CHANGED_FILES" | sed 's#website/docs/docs/##; s/.md$//' | awk -v url="$DEPLOYMENT_URL" '{print "- [" $0 "](" url "/docs/" $0 ")"}') fi - # Output the links - echo -e "links=$LINKS" >> $GITHUB_OUTPUT + echo "links=$LINKS" >> $GITHUB_OUTPUT + - name: Post comment with deployment link uses: peter-evans/create-or-update-comment@v4