Skip to content
This repository has been archived by the owner on Dec 6, 2022. It is now read-only.

Run chromatic directly on dependabot PRs #1179

Merged
merged 2 commits into from
Nov 25, 2021

Conversation

jamie-lynch
Copy link

What is the purpose of this change?

As of March 2021, workflows triggered by a push event don't have access to GitHub secrets, if that event originates from a fork of the repo. As a result, PRs raised by Dependabot are not able to trigger a Chromatic run.

In #1112 we introduced a workaround:

Here I am creating a special workflow that completes successfully if the user raising the PR is Dependabot.

When this completes, the Chromatic workflow is triggered by the workflow_run event. Workflows triggered by this event > have access to secrets, so can successfully run Chromatic.

Recently we discovered that the chromatic workflow was running multiple times against the same commit for a dependabot PR, increasing the number of snapshots and therefore the bill for chromatic.

#1177 updated the workflow to allow chromatic to be triggered by the workflow_dispatch event, i.e. manually. The hope was that this would let us manually run the step for dependabot PRs just before they were merged. Unfortunately, an error occurred when running the workflow manually.

This PR reverts those changes and returns us to the situation where chromatic will run automatically on a dependabot PR but fail due to a lack of token. Whilst this is not ideal, it is possible to manually rerun the workflow successfully. This means that we retain chromatic checks on dependabot PRs but only have to run the workflow once, reducing the number of snapshots consumer.

@jamie-lynch jamie-lynch requested a review from a team as a code owner November 17, 2021 14:46
@jamie-lynch
Copy link
Author

cc @jfsoul

Trying out a return to manual reruns, not ideal developer experience but we managed like this for a few months without great difficultly so (I think) this is a reasonable compromise until we can think of something better

@jfsoul
Copy link

jfsoul commented Nov 17, 2021

Thanks @jamie-lynch - I can't approve this on behalf of the team - it's your workflow and your call - but it seems sensible to me!

On the multiple builds for the same commit - I had a suspicion after looking at those that it may be a red herring. While the GHA UI identifies the commit as the same:
image
image
image

When you actually look at the commits that Chromatic uses, they are indeed different (and I think valid commits to build for):

image
image

I wondered whether this is perhaps more to do with the way the actions/checkout works for workflows triggered by workflow_run? (assuming this is what github use for the actions UI to identify commit ID)

@jamie-lynch jamie-lynch merged commit 99f4da0 into main Nov 25, 2021
@jamie-lynch jamie-lynch deleted the remove-dependabot-workaround branch November 25, 2021 09:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants