Skip to content

Percy screenshots

Percy screenshots #198

# This workflow listens for completion of the `pr-percy-prepare` workflows, picks up their outputs, and performs Percy testing.
name: "Percy screenshots"
on:
workflow_run:
workflows:
- "Percy (pushed)"
- "Percy (labeled)"
types:
- completed
jobs:
upload:
name: Build project with proposed changes & take Percy snapshots
if: github.event.workflow_run.conclusion=='success'
runs-on: ubuntu-latest
outputs:
pr_head_sha: ${{ steps.get_pr_data.outputs.sha }}
pr_number: ${{ steps.get_pr_data.outputs.pr_number }}
percy_build_link: ${{ steps.percy_snapshot.outputs.build_link }}
percy_org_id: ${{ steps.percy_snapshot.outputs.org_id }}
percy_build_id: ${{ steps.percy_snapshot.outputs.build_id }}
steps:
- name: Checkout SCM
uses: actions/checkout@v4
- name: Remove SCM directories that will be replaced by artifact files
run: |
set -e
rm -rf templates/docs/examples/ templates/_macros/ tokens/ sd.config.json scss/
- name: Download artifact from workflow run
uses: actions/download-artifact@v4
with:
name: "percy-testing-web-artifact"
github-token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.event.workflow_run.repository.full_name }}
run-id: ${{ github.event.workflow_run.id }}
- name: Move artifact files into place to replace SCM
run: |
# ensure the examples & macros dirs exist for backwards compatibility in case they aren't in the PR artifact
mkdir -p examples
mkdir -p macros
mkdir -p tokens
# artifact directory contains `scss/`, `examples/`, `macros/`, 'tokens/', 'sd.config.json', `pr_num.txt`, and `pr_head_sha.txt`.
# `/examples` and `macros/` must be moved to `templates/`.
mv examples/ templates/docs/.
mv macros/ templates/_macros
- name: Get PR data
if: github.event.workflow_run.event=='pull_request'
id: get_pr_data
run: |
echo "sha=$(cat pr_head_sha.txt)" >> $GITHUB_OUTPUT
echo "pr_number=$(cat pr_num.txt)" >> $GITHUB_OUTPUT
tree
- name: Take snapshots & upload to Percy
id: percy_snapshot
uses: "./.github/actions/percy-snapshot"
with:
branch_name: "pull/${{ steps.get_pr_data.outputs.pr_number }}"
pr_number: ${{ steps.get_pr_data.outputs.pr_number }}
commitsh: ${{ steps.get_pr_data.outputs.sha }}
percy_token_write: ${{ secrets.PERCY_TOKEN_WRITE }}