Skip to content

Harden Storybook PR preview workflow and patch vulnerable artifact download action - #22

Draft
fabio-silva with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-code-review-comment
Draft

Harden Storybook PR preview workflow and patch vulnerable artifact download action#22
fabio-silva with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-code-review-comment

Conversation

Copilot AI commented May 22, 2026

Copy link
Copy Markdown
Contributor

This PR addresses the workflow security review feedback by separating untrusted PR build execution from privileged deployment, and patches the vulnerable actions/download-artifact version used in the deploy path.

  • Workflow trust boundary split

    • Converted PR preview build to run on pull_request with read-only token scope.
    • Moved privileged preview publish/remove operations into a separate trusted workflow triggered by workflow_run (deploy) and pull_request_target (close cleanup).
  • Permission minimization

    • Build job no longer holds write-scoped permissions.
    • Deploy/remove jobs retain contents: write / pull-requests: write only where required.
  • Safe artifact-based deploy flow

    • Build workflow uploads storybook-static as an artifact.
    • Deploy workflow downloads artifact from the completed build run and publishes preview for the resolved PR number.
    • Added guard logic for workflow_run events with no associated PR payload.
  • Vulnerability remediation

    • Updated actions/download-artifact from @v4 to @v4.1.3 in deploy workflow to avoid the arbitrary file write vulnerability affecting <4.1.3.
- name: Download Storybook artifact
  uses: actions/download-artifact@v4.1.3
  with:
    name: storybook-static
    path: storybook-static
    github-token: ${{ secrets.GITHUB_TOKEN }}
    run-id: ${{ github.event.workflow_run.id }}

Copilot AI and others added 3 commits May 22, 2026 10:38
Agent-Logs-Url: https://github.com/percona/percona-ui/sessions/acdbb664-ae32-4e50-b38b-724a92985a0b

Co-authored-by: fabio-silva <4190654+fabio-silva@users.noreply.github.com>
Agent-Logs-Url: https://github.com/percona/percona-ui/sessions/acdbb664-ae32-4e50-b38b-724a92985a0b

Co-authored-by: fabio-silva <4190654+fabio-silva@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix code based on review comment Harden Storybook PR preview workflow and patch vulnerable artifact download action May 22, 2026
Copilot AI requested a review from fabio-silva May 22, 2026 10:46
@fabio-silva
fabio-silva requested a review from Copilot June 24, 2026 10:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens the Storybook PR preview pipeline by splitting untrusted PR build execution from privileged deploy/cleanup operations, and updates the deploy path to use a patched actions/download-artifact version.

Changes:

  • Added a pull_request workflow to build Storybook and upload storybook-static as an artifact with read-only token scope.
  • Added a trusted deploy/cleanup workflow triggered by workflow_run (deploy) and pull_request_target (close cleanup) with scoped write permissions.
  • Patched the deploy workflow to use actions/download-artifact@v4.1.3.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
.github/workflows/storybook-preview.yml New PR build workflow that uploads the Storybook static output as an artifact.
.github/workflows/storybook-preview-deploy.yml New trusted deploy/cleanup workflow that downloads artifacts from the build run and publishes/removes PR previews.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +19 to +22
- name: Checkout PR head
uses: actions/checkout@v5
with:
persist-credentials: false
Comment on lines +30 to +34
- name: Upload Storybook artifact
uses: actions/upload-artifact@v4
with:
name: storybook-static
path: storybook-static
Comment on lines +18 to +20
permissions:
contents: write
pull-requests: write
Comment on lines +10 to +12
concurrency:
group: pr-preview-${{ github.event.pull_request.number || github.event.workflow_run.id }}
cancel-in-progress: true
Comment on lines +41 to +47
- name: Deploy PR preview
if: steps.pr.outputs.skip != 'true'
uses: rossjrw/pr-preview-action@v1
with:
action: deploy
source-dir: ./storybook-static
pr-number: ${{ steps.pr.outputs.number }}
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.

3 participants