Skip to content

fix: update preview workflow - #171

Merged
banana-three-join merged 1 commit into
layer5io:masterfrom
banana-three-join:fix/banana-three-join/update-preview-workflow
Aug 4, 2026
Merged

banana-three-join merged 1 commit into
layer5io:masterfrom
banana-three-join:fix/banana-three-join/update-preview-workflow

Conversation

@banana-three-join

@banana-three-join banana-three-join commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Notes for Reviewers

Signed commits

  • Yes, I signed my commits.

Summary by CodeRabbit

  • New Features

    • Added automated documentation previews for pull requests.
    • Preview builds now include no-index metadata to prevent search engine indexing.
    • Preview links are posted automatically on pull requests.
    • Added cleanup and retention of older documentation previews.
  • Chores

    • Replaced the previous site preview workflow with the new documentation preview process.

Signed-off-by: Lenox Wiltshire <lenoxwiltshire@gmail.com>
@coderabbitai

coderabbitai Bot commented Aug 4, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The previous preview workflow was removed. Separate workflows now build documentation previews, upload build metadata, deploy or remove previews, prune older previews, and update pull-request comments.

Changes

Documentation Preview Delivery

Layer / File(s) Summary
Build documentation preview
.github/workflows/build-docs-preview.yml, .github/workflows/build-and-preview-site.yml
The new workflow builds non-indexed documentation previews for relevant pull requests, records pull-request metadata, and uploads artifacts. The previous combined preview workflow was deleted.
Deploy or remove pull-request preview
.github/workflows/deploy-docs-preview.yml
The deployment workflow validates metadata, retrieves artifacts, deploys or removes previews, and updates pull-request comments.
Prune retained previews and notify pull requests
.github/workflows/deploy-docs-preview.yml
The workflow retains six recent previews, retries concurrent gh-pages updates, and reports removed previews in pull-request comments.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PullRequest
  participant BuildDocsPreview
  participant ArtifactStorage
  participant DeployDocsPreview
  participant GitHubPages
  PullRequest->>BuildDocsPreview: trigger preview build
  BuildDocsPreview->>ArtifactStorage: upload preview and PR metadata
  ArtifactStorage->>DeployDocsPreview: provide artifacts
  DeployDocsPreview->>GitHubPages: deploy or remove preview
  DeployDocsPreview->>PullRequest: update preview comment
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change to the preview workflow.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/build-docs-preview.yml:
- Line 26: Update the workflow so metadata creation and upload of the pr/action
artifact run for closed pull requests as well, using an always-running job. Keep
dependency installation and npm run build:preview conditional on
github.event.action != 'closed', while preserving the existing preview-removal
flow’s access to the uploaded artifact.

In @.github/workflows/deploy-docs-preview.yml:
- Around line 101-104: Update the prune job’s needs declaration so it depends on
both read-metadata and deploy, while preserving its existing runs-on and action
condition. This ensures pruning runs only after deployment completes.
- Around line 8-11: Remove the workflow-level contents: write and pull-requests:
write permissions, leaving only actions: read globally. Add contents: write and
pull-requests: write under the permissions for the deploy and prune jobs, while
keeping read-metadata limited to actions: read.
- Around line 33-39: Replace the mutable action tags with full commit-SHA
references in .github/workflows/deploy-docs-preview.yml: pin both
actions/download-artifact uses at lines 33-39 and 70-76, actions/checkout at
lines 109-116, and actions/github-script at lines 203-208. Preserve each
action’s existing version and configuration while ensuring all four references
resolve to immutable commits.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 23522f73-051a-4920-a65b-262fac1375bf

📥 Commits

Reviewing files that changed from the base of the PR and between 7032962 and 1de6a7c.

📒 Files selected for processing (3)
  • .github/workflows/build-and-preview-site.yml
  • .github/workflows/build-docs-preview.yml
  • .github/workflows/deploy-docs-preview.yml
💤 Files with no reviewable changes (1)
  • .github/workflows/build-and-preview-site.yml

jobs:
build-docs-preview:
runs-on: ubuntu-24.04
if: github.event.action != 'closed'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Preserve metadata for closed pull requests.

Line 26 skips the only job that writes and uploads pr/action. A closed event then has no docs-preview-build artifact. .github/workflows/deploy-docs-preview.yml cannot read the action or run the preview removal flow.

Move metadata creation and artifact upload to an always-running job. Run dependency installation and npm run build:preview only when the action is not closed.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/build-docs-preview.yml at line 26, Update the workflow so
metadata creation and upload of the pr/action artifact run for closed pull
requests as well, using an always-running job. Keep dependency installation and
npm run build:preview conditional on github.event.action != 'closed', while
preserving the existing preview-removal flow’s access to the uploaded artifact.

Comment on lines +8 to +11
permissions:
contents: write
pull-requests: write
actions: read

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Scope write permissions to the jobs that require them.

read-metadata downloads and parses a pull-request artifact, but it only requires actions: read. Move contents: write and pull-requests: write to the deploy and prune jobs. This reduces the privileged workflow_run attack surface.

🧰 Tools
🪛 zizmor (1.28.0)

[error] 9-9: overly broad permissions (excessive-permissions): contents: write is overly broad at the workflow level

(excessive-permissions)


[error] 10-10: overly broad permissions (excessive-permissions): pull-requests: write is overly broad at the workflow level

(excessive-permissions)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/deploy-docs-preview.yml around lines 8 - 11, Remove the
workflow-level contents: write and pull-requests: write permissions, leaving
only actions: read globally. Add contents: write and pull-requests: write under
the permissions for the deploy and prune jobs, while keeping read-metadata
limited to actions: read.

Source: Linters/SAST tools

Comment on lines +33 to +39
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: docs-preview-build
path: docs-preview-build
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

for ref in \
  actions/download-artifact@v4 \
  actions/checkout@v6 \
  actions/github-script@v8
do
  repo="${ref%@*}"
  tag="${ref#*@}"
  sha="$(gh api "repos/${repo}/commits/${tag}" --jq .sha)"
  printf '%s@%s # %s\n' "$repo" "$sha" "$tag"
done

Repository: layer5io/academy-example

Length of output: 365


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf 'Workflow action references in deploy-docs-preview.yml:\n'
rg -n 'uses:\s*[^#\s]+@[^\s]+' .github/workflows/deploy-docs-preview.yml || true

printf '\nResolved full SHA for referenced tags:\n'
python3 - <<'PY'
import re
from subprocess import run, PIPE

path = '.github/workflows/deploy-docs-preview.yml'
text = open(path).read()
refs = re.findall(r'uses:\s*([^#\s]+)', text)
for ref in refs:
    repo, tag = ref.rsplit('@', 1)
    result = run(['gh', 'api', f'repos/{repo}/commits/{tag}'], text=True, capture_output=True)
    sha = None
    if result.returncode == 0:
        import json
        sha = json.loads(result.stdout)['sha']
    print(f'{path}: uses={ref} -> sha={sha!r}')
PY

Repository: layer5io/academy-example

Length of output: 2231


Pin the mutable GitHub Action refs to commit SHAs.

This workflow still uses mutable tags at the following locations:

  • .github/workflows/deploy-docs-preview.yml#L34 / L71: actions/download-artifact@v4
  • .github/workflows/deploy-docs-preview.yml#L110: actions/checkout@v6
  • .github/workflows/deploy-docs-preview.yml#L204: actions/github-script@v8

Pin these to full commit SHAs so downstream action changes cannot execute through this workflow.

📍 Affects 1 file
  • .github/workflows/deploy-docs-preview.yml#L33-L39 (this comment)
  • .github/workflows/deploy-docs-preview.yml#L70-L76
  • .github/workflows/deploy-docs-preview.yml#L109-L116
  • .github/workflows/deploy-docs-preview.yml#L203-L208
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/deploy-docs-preview.yml around lines 33 - 39, Replace the
mutable action tags with full commit-SHA references in
.github/workflows/deploy-docs-preview.yml: pin both actions/download-artifact
uses at lines 33-39 and 70-76, actions/checkout at lines 109-116, and
actions/github-script at lines 203-208. Preserve each action’s existing version
and configuration while ensuring all four references resolve to immutable
commits.

Source: Linters/SAST tools

Comment on lines +101 to +104
prune:
needs: read-metadata
runs-on: ubuntu-24.04
if: needs.read-metadata.outputs.action != 'closed'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Run pruning after deployment.

deploy and prune start concurrently because both depend only on read-metadata. If gh-pages already has six previews, prune can exit without changes before deploy adds a seventh preview.

Make prune depend on both read-metadata and deploy.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/deploy-docs-preview.yml around lines 101 - 104, Update the
prune job’s needs declaration so it depends on both read-metadata and deploy,
while preserving its existing runs-on and action condition. This ensures pruning
runs only after deployment completes.

@banana-three-join
banana-three-join merged commit 2f99254 into layer5io:master Aug 4, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants