Skip to content

Commit 74a81f7

Browse files
Copilotskjnldsv
andauthored
fix: match actual Netlify 'Draft URL: <url>' output format
Agent-Logs-Url: https://github.com/nextcloud/documentation/sessions/09c9207a-a095-4936-bfa5-ea1de5218fd8 Co-authored-by: skjnldsv <14975046+skjnldsv@users.noreply.github.com>
1 parent d4ee210 commit 74a81f7

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

.github/workflows/sphinxbuild.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)