Skip to content

Commit 06c39e4

Browse files
committed
fix: fixing deployment location for PRs
1 parent 659c672 commit 06c39e4

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

.github/workflows/jekyll.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,28 @@ jobs:
6969
preview: ${{ github.event_name == 'pull_request' }}
7070
- name: Output deployment URL
7171
if: always()
72+
env:
73+
GH_TOKEN: ${{ github.token }}
7274
run: |
73-
echo "GitHub Pages URL: ${{ steps.deployment.outputs.page_url }}" >> "$GITHUB_STEP_SUMMARY"
75+
# Query the latest GitHub Pages deployment for this repo and extract its page_url
76+
RAW=$(gh api -H "Accept: application/vnd.github+json" \
77+
repos/${{ github.repository }}/pages/deployments \
78+
--method GET --paginate -f per_page=1)
79+
URL=$(python - <<'PY'
80+
import json,sys
81+
data=json.loads(sys.stdin.read())
82+
if isinstance(data,list) and data:
83+
print(data[0].get('page_url') or '')
84+
else:
85+
print('')
86+
PY
87+
<<< "$RAW")
88+
if [ -n "$URL" ]; then
89+
if [ "${{ github.event_name }}" = "pull_request" ]; then
90+
echo "Preview deployment URL: $URL" >> "$GITHUB_STEP_SUMMARY"
91+
else
92+
echo "Production deployment URL: $URL" >> "$GITHUB_STEP_SUMMARY"
93+
fi
94+
else
95+
echo "Deployment completed. Open the PR and click 'View deployment' under 'GitHub Pages - Preview' to access the preview URL." >> "$GITHUB_STEP_SUMMARY"
96+
fi

0 commit comments

Comments
 (0)