Skip to content

Testing Percy on fork PR #2618 #4011

Testing Percy on fork PR #2618

Testing Percy on fork PR #2618 #4011

Workflow file for this run

# See .github/PERCY.md for when Percy runs, the watched-paths list, and how to force a run.
name: Percy testing on PRs from forks
run-name: "Testing Percy on fork PR #${{ github.event.pull_request.number }}"
# This workflow handles Percy testing for PRs from forks securely
# It uses pull_request_target to access secrets while checking out the PR code
on:
pull_request_target:
branches:
- main
types:
- opened
- synchronize
- reopened
- ready_for_review
- labeled
- unlabeled
permissions:
contents: read
pull-requests: read
concurrency:
group: percy-fork-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
decide:
name: Decide whether to run Percy
runs-on: ubuntu-latest
# Only run for forks; internal PRs use percy-pr.yaml
if: github.event.pull_request.head.repo.full_name != github.repository
outputs:
should_run: ${{ steps.gate.outputs.should_run }}
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: .github/actions/percy-gate
sparse-checkout-cone-mode: false
persist-credentials: false
- id: gate
uses: ./.github/actions/percy-gate
with:
mode: pr
snapshot:
name: Take Percy snapshots
runs-on: ubuntu-latest
needs: decide
if: needs.decide.result == 'success' && needs.decide.outputs.should_run == 'true'
# The environment "percy-testing" handles the approval gate
environment: percy-testing
steps:
- name: Checkout Trusted Action
uses: actions/checkout@v4
with:
path: trusted-logic
persist-credentials: false
- name: Checkout PR code
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
path: untrusted-pr-code
persist-credentials: false
- uses: ./trusted-logic/.github/actions/percy-snapshot
with:
project_root: ./untrusted-pr-code
pr_number: ${{ github.event.pull_request.number }}
branch_name: ${{ github.event.pull_request.head.ref }}
commitsh: ${{ github.event.pull_request.head.sha }}
percy_token_write: ${{ secrets.PERCY_TOKEN_WRITE }}