File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -634,16 +634,19 @@ jobs:
634634 continue-on-error : true
635635 run : |
636636 set +e
637- json =$(netlify deploy \
637+ output =$(netlify deploy \
638638 --dir=netlify-deploy \
639639 --site="${{ secrets.NETLIFY_SITE_ID }}" \
640640 --auth="${{ secrets.NETLIFY_AUTH_TOKEN }}" \
641641 --alias="pr-${{ github.event.pull_request.number }}" \
642- --message="Preview for PR #${{ github.event.pull_request.number }}" \
643- --json 2>/dev/null)
642+ --message="Preview for PR #${{ github.event.pull_request.number }}" 2>&1)
644643 exit_code=$?
645- echo "$json"
646- preview_url=$(echo "$json" | jq -r '.deploy_url // .url // ""' 2>/dev/null || echo "")
644+ echo "$output"
645+ # Strip ANSI codes, then extract the URL from "Draft URL: <https://...>"
646+ preview_url=$(printf '%s\n' "$output" \
647+ | sed 's/\x1b\[[0-9;]*[mGKHFJABCDsuKl]//g' \
648+ | grep -oP '(?:Draft URL|Website Draft URL|Website URL):\s+<?https://\K[^>\s]+' \
649+ | head -1)
647650 echo "url=${preview_url}" >> "$GITHUB_OUTPUT"
648651 exit $exit_code
649652
You can’t perform that action at this time.
0 commit comments