Skip to content

Commit 0087035

Browse files
committed
ENH: Align workflow with lecture-python.myst configuration
- Add PR event types (opened, synchronize, reopened) - Remove branch restrictions on pull_request to work for all PRs - Add workflow_dispatch input for preview_page - Add --context flags to Netlify deploy (pr-preview, dev) - Add manual preview page support in PR comments
1 parent 8779539 commit 0087035

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

.github/workflows/ci_pr.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@ name: Build and Netlify Deploy
22

33
on:
44
pull_request:
5-
branches:
6-
- main
7-
- theme_updates
5+
types: [opened, synchronize, reopened]
86
push:
97
branches:
108
- theme_updates
119
workflow_dispatch:
10+
inputs:
11+
preview_page:
12+
description: 'Specific page to preview (e.g., intro.html)'
13+
required: false
14+
type: string
1215

1316
concurrency:
1417
group: ${{ github.workflow }}-${{ github.ref }}
@@ -75,6 +78,7 @@ jobs:
7578
--dir lectures/_build/html/ \
7679
--site ${{ secrets.NETLIFY_SITE_ID }} \
7780
--auth ${{ secrets.NETLIFY_AUTH_TOKEN }} \
81+
--context pr-preview \
7882
--alias pr-${{ github.event.pull_request.number }} \
7983
--message "${deploy_message}" \
8084
--json)
@@ -88,6 +92,12 @@ jobs:
8892
echo "deploy_url=$deploy_url" >> $GITHUB_OUTPUT
8993
echo "✅ Deployment completed!"
9094
echo "🌐 Deploy URL: $deploy_url"
95+
96+
# Display manual preview page if specified
97+
if [ ! -z "${{ github.event.inputs.preview_page }}" ]; then
98+
echo ""
99+
echo "🎯 Manual preview page: ${deploy_url}/${{ github.event.inputs.preview_page }}"
100+
fi
91101
else
92102
# Handle push to branch
93103
deploy_message="Deploy from GitHub Actions (commit: ${{ github.sha }})"
@@ -96,6 +106,7 @@ jobs:
96106
--dir lectures/_build/html/ \
97107
--site ${{ secrets.NETLIFY_SITE_ID }} \
98108
--auth ${{ secrets.NETLIFY_AUTH_TOKEN }} \
109+
--context dev \
99110
--alias ${{ github.ref_name }} \
100111
--message "${deploy_message}" \
101112
--json)
@@ -120,11 +131,13 @@ jobs:
120131
with:
121132
script: |
122133
const deployUrl = `${{ steps.netlify-deploy.outputs.deploy_url }}`;
134+
const manualPage = `${{ github.event.inputs.preview_page }}`;
123135
const prNumber = ${{ github.event.pull_request.number }};
124136
const commitSha = `${{ github.event.pull_request.head.sha }}`;
125137
const shortSha = commitSha.substring(0, 7);
126138
127139
console.log(`Deploy URL: ${deployUrl}`);
140+
console.log(`Manual preview page: ${manualPage}`);
128141
console.log(`PR Number: ${prNumber}`);
129142
console.log(`Commit SHA: ${shortSha}`);
130143
@@ -157,6 +170,12 @@ jobs:
157170
158171
let comment = `**📖 Netlify Preview Ready!**\n\n`;
159172
comment += `**Preview URL:** ${deployUrl} ([${shortSha}](${commitUrl}))\n\n`;
173+
174+
// Add manual preview page if specified
175+
if (manualPage) {
176+
comment += `🎯 **Manual Preview:** [${manualPage}](${deployUrl}/${manualPage})\n\n`;
177+
}
178+
160179
comment += `✨ Browse the preview at the URL above.\n`;
161180
162181
// Post the comment

0 commit comments

Comments
 (0)