diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 42d1007c..497fbf4c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -191,10 +191,34 @@ jobs: # times, and the nightly is what keeps asking. Chromatic answers "should # this have changed?", which only makes sense once the answer to "did # anything change by itself?" is no. + # + # `CHROMATIC_SHA`, and the branch and slug that have to travel with it, + # because on a `pull_request` event `GITHUB_SHA` is the *merge* commit + # GitHub builds for the run -- a commit that exists on no branch. Left + # alone, Chromatic posts `UI Tests` and `UI Review` there, where the pull + # request shows them (GitHub knows the merge commit is its) but a + # required status check cannot: those are read off the head commit, + # which is where every Actions job already reports. Measured on #187: + # twelve check runs on `5520f5f2`, three Chromatic statuses on the merge + # commit `aefcbe4`, no overlap. + # + # It also picks the wrong baseline. That merge commit has the latest + # build on main for an ancestor -- the pull request's own branch does + # not -- so every comparison is made against main rather than against + # what this branch last looked like. + # + # Chromatic's own answer is to run this on `push` instead, which for + # this workflow would mean the whole 20-minute sweep on every branch + # push, pull request or not. So: the documented alternative, verbatim, + # falling back to the push values on main. + # - run: pnpm chromatic ${{ github.ref == 'refs/heads/main' && '--auto-accept-changes' || '--exit-zero-on-changes' }} if: ${{ env.CHROMATIC == 'true' }} env: CHROMATIC_PROJECT_TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} + CHROMATIC_SHA: ${{ github.event.pull_request.head.sha || github.sha }} + CHROMATIC_BRANCH: ${{ github.event.pull_request.head.ref || github.ref_name }} + CHROMATIC_SLUG: ${{ github.repository }} # # Build