Add Netlify preview deployment for pull requests#14401
Add Netlify preview deployment for pull requests#14401
Conversation
679ff52 to
cfc3d01
Compare
Agent-Logs-Url: https://github.com/nextcloud/documentation/sessions/12ab3238-1214-4ff1-b0cf-67836a1abc12 Co-authored-by: skjnldsv <14975046+skjnldsv@users.noreply.github.com>
Agent-Logs-Url: https://github.com/nextcloud/documentation/sessions/131cd607-27ec-4bd2-abed-7ede744acad9 Co-authored-by: skjnldsv <14975046+skjnldsv@users.noreply.github.com>
cfc3d01 to
1d35c34
Compare
|
@copilot the gh-pages already contains everything. You don't have to build a new index.html or something. Maybe you can just add the netlify step into the deploy job ? So we avoid caching and restoring 2GB again? If it's a PR, deploy to detlify, if not, create the PR against gh-pages as it currently is ? |
…und-trip Agent-Logs-Url: https://github.com/nextcloud/documentation/sessions/1f6603ff-c52e-4e41-bf59-d23447600bfb Co-authored-by: skjnldsv <14975046+skjnldsv@users.noreply.github.com>
…simple index.html Agent-Logs-Url: https://github.com/nextcloud/documentation/sessions/af4f573e-5b1e-4d54-bae0-dbfec917b30c Co-authored-by: skjnldsv <14975046+skjnldsv@users.noreply.github.com>
Add Netlify preview deployment for pull requests
Agent-Logs-Url: https://github.com/nextcloud/documentation/sessions/fd9abf90-6eb8-4986-ae43-4ce3c769083e Co-authored-by: skjnldsv <14975046+skjnldsv@users.noreply.github.com>
Done in 937510e. The separate
No new cache step is needed since gh-pages is already checked out and the staged artifacts are applied before the Netlify deploy runs. |
…sts in gh-pages Agent-Logs-Url: https://github.com/nextcloud/documentation/sessions/a6ca17cd-be62-49ee-91e1-82877e91b614 Co-authored-by: skjnldsv <14975046+skjnldsv@users.noreply.github.com>
Co-authored-by: skjnldsv <14975046+skjnldsv@users.noreply.github.com>
…sions Agent-Logs-Url: https://github.com/nextcloud/documentation/sessions/b646b2ff-3537-46cc-a405-f5bb8926e7d3 Co-authored-by: skjnldsv <14975046+skjnldsv@users.noreply.github.com>
Agent-Logs-Url: https://github.com/nextcloud/documentation/sessions/c2b4d982-2c08-48d7-9ad7-7a462e079cbe Co-authored-by: skjnldsv <14975046+skjnldsv@users.noreply.github.com>
…t method Agent-Logs-Url: https://github.com/nextcloud/documentation/sessions/9a18eeec-8e48-41ef-a446-41b121aea921 Co-authored-by: skjnldsv <14975046+skjnldsv@users.noreply.github.com>
Agent-Logs-Url: https://github.com/nextcloud/documentation/sessions/18b676be-3c6e-4ee5-8096-6711e6577d13 Co-authored-by: skjnldsv <14975046+skjnldsv@users.noreply.github.com>
Agent-Logs-Url: https://github.com/nextcloud/documentation/sessions/bd55ee68-16b8-498e-beb0-fb8ed14f7b6b Co-authored-by: skjnldsv <14975046+skjnldsv@users.noreply.github.com>
…oint Agent-Logs-Url: https://github.com/nextcloud/documentation/sessions/5b0532ef-f50b-4b3c-8231-8265472bf35f Co-authored-by: skjnldsv <14975046+skjnldsv@users.noreply.github.com>
|
🚀 Netlify preview deployed: https://pr-14401--nextcloud-documentation.netlify.app |
…ons) Agent-Logs-Url: https://github.com/nextcloud/documentation/sessions/9b9ff82f-f385-4158-8d94-19585a65a684 Co-authored-by: skjnldsv <14975046+skjnldsv@users.noreply.github.com>
PUT .../pincall — GitHub's pin-comment API rejects PR issue numbers and requires write access the GITHUB_TOKEN doesn't have on pull_request eventsOriginal prompt
Goal
Add a
netlify-previewjob to the existing.github/workflows/sphinxbuild.ymlworkflow that deploys a full documentation preview to Netlify for every pull request, with a stable per-PR URL.How the existing workflow works
The
sphinxbuild.ymlworkflow already:buildjob: builds all 3 manuals (user_manual,admin_manual,developer_manual) and uploads them as artifactsstage-and-checkjob: downloads all artifacts, assembles them intostage/<branch_name>/(e.g.stage/latest/), and saves it to an Actions cache keyed bystaged-docs-${{ github.sha }}deployjob: only runs onpush(not PRs), deploys to gh-pagesWhat needs to be added
Add a new job
netlify-previewto the workflow with the following behaviour:Trigger
pull_requestevents (if: github.event_name == 'pull_request')stage-and-check(needs: stage-and-check)Steps
Restore the staged cache using
actions/cache/restorewith keystaged-docs-${{ github.sha }}— this is already saved bystage-and-check, so no rebuild is needed.Assemble the Netlify deploy directory: The
stage/folder has the structurestage/<branch_name>/<manual_name>/. Flatten this into anetlify-deploy/directory like:The root
index.htmlshould be a minimal HTML page with links to each manual subdirectory.Deploy to Netlify using
nwtgck/actions-netlify@v3with:publish-dir: netlify-deployalias: pr-${{ github.event.pull_request.number }}— gives a stable per-PR URL likehttps://pr-42--<site-name>.netlify.appgithub-token: ${{ secrets.GITHUB_TOKEN }}— so it posts a comment on the PR with the preview URLdeploy-message: "PR #${{ github.event.pull_request.number }} preview"enable-pull-request-comment: trueenable-commit-comment: falseoverwrites-pull-request-comment: trueNETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}Permissions
The
netlify-previewjob needs:Summary job update
Update the existing
summaryjob'sneedsarray to includenetlify-preview, and update the summary step logic to handle it correctly:netlify-previewmust succeed (or be skipped if secrets aren't set)netlify-previewmust be skippedThe condition in the summary should gracefully handle the case where
NETLIFY_AUTH_TOKEN/NETLIFY_SITE_IDsecrets are not yet configured (the netlify action will simply fail in that case, so the summary should treatresult == 'skipped' || result == 'success'as acceptable for PRs).Notes
build,stage-and-check, ordeployjobs.stage-and-check.nwtgck/actions-netlifyaction to a specific commit SHA (usev3tag resolved to its SHA, or usenwtgck/actions-netlify@v3.0.0if a specific SHA isn't available — check the action's repo for the latest pinnable SHA).stage/<branch_name>/subfolder name comes fromneeds.stage-and-check.outputs.branch_name.NETLIFY_AUTH_TOKENandNETLIFY_SITE_IDmust be set as repository secrets.The following is the prior conversation context from the user's chat exploration (may be truncated):
User: Do you think you can use the sphinxbuild workflow and deploy the documentation on netlify so we can have a temporary overview of a PR ?
The staging step should provide a full set of how the docs is supposed to look.
Assistant: Yes, absolutely! I have a clear picture of what's needed. Here's what the existing workflow already has:
buildjob: builds all 3 manuals (user, admin, developer) as artifactsstage-and-checkjob: assembles them into astage/<branch>/folder, cached by SHAdeployjob: deploys to gh-pages (push only)The plan is to add a new
netlify-previewjob that:stage-and-checkstage/folder (no extra build cost)pr-<number>) for a stable URLThis requires two repository secrets to be configured:
NETLIFY_AUTH_TOKENandNETLIFY_SITE_ID.Shall I open a PR with the workflow changes?
User: What would the URLs look like ? Ideally one for each PR ?
Assistant: With the `alias: pr-${{ github.event.pull_req...
This pull request was created from Copilot chat.