Skip to content

Fix deploy preview workflow: permissions, keep_files, cleanup#10

Closed
Copilot wants to merge 2 commits into
mainfrom
copilot/debug-deploy-preview-issue
Closed

Fix deploy preview workflow: permissions, keep_files, cleanup#10
Copilot wants to merge 2 commits into
mainfrom
copilot/debug-deploy-preview-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 27, 2026

PR #7's deploy preview workflow fails with 403 on the PR comment step because it only declares contents: write but actions/github-script needs pull-requests: write. Additionally, the main deploy would wipe PR preview subdirectories, and stale previews were never cleaned up.

Changes

  • Permission fix: Add pull-requests: write to workflow permissions
  • Preserve PR previews on main deploy: Add keep_files: true to the peaceiris/actions-gh-pages step for main, so deploying main doesn't nuke pr/*/ subdirectories
  • Cleanup job: New cleanup-preview job triggers on pull_request: closed to git rm the PR's preview directory from gh-pages
  • trace_viewer.html: Add ?trace=URL query parameter support for auto-loading traces (enables the demo redirect)
  • demo/index.html: Meta-refresh redirect to trace_viewer.html?trace=demo.bin

Workflow structure

on:
  pull_request:
    types: [opened, synchronize, reopened, closed]  # closed triggers cleanup only

jobs:
  deploy:        # build + deploy; skipped on PR close
  cleanup-preview:  # rm pr/<number>/ from gh-pages; runs on PR close only

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…r main deploy, PR cleanup job

PR #7 failed because the workflow only had `contents: write` permission
but the PR comment step requires `pull-requests: write`. Additional fixes:
- Add `keep_files: true` to main deploy so PR preview subdirectories
  are not deleted when main is deployed
- Add `cleanup-preview` job to remove PR preview directories when PRs
  are closed/merged
- Add `?trace=URL` auto-load parameter to trace_viewer.html
- Add demo/index.html redirect for the deployed demo

Co-authored-by: rcoh <492903+rcoh@users.noreply.github.com>
Copilot AI changed the title [WIP] Investigate deploy preview functionality breakdown Fix deploy preview workflow: permissions, keep_files, cleanup Feb 27, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Trace Viewer Preview: https://dial9-rs.github.io/dial9-tokio-telemetry/pr/10/

@rcoh rcoh closed this Mar 1, 2026
@rcoh rcoh deleted the copilot/debug-deploy-preview-issue branch March 25, 2026 01:06
@jlizen jlizen mentioned this pull request Apr 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants