From 6da4ef394a29ef43bf25322c4db9b948d10d73e8 Mon Sep 17 00:00:00 2001 From: George B <705427+georgeblahblah@users.noreply.github.com> Date: Fri, 12 Jan 2024 08:38:46 +0000 Subject: [PATCH] Add reminder to add `run_chromatic` label (#9447) * Add reminder to add `run_chromatic` label * Run Chromatic label helper when PR is ready for review * Include link to Chromatic project --- .github/workflows/chromatic-label-helper.yml | 45 ++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/chromatic-label-helper.yml diff --git a/.github/workflows/chromatic-label-helper.yml b/.github/workflows/chromatic-label-helper.yml new file mode 100644 index 00000000000..8f54cfbc780 --- /dev/null +++ b/.github/workflows/chromatic-label-helper.yml @@ -0,0 +1,45 @@ +# The DCR repo has a required status check on the Chromatic UI Tests +# To save £££, we only run the Chromatic tests once the `run_chromatic` +# label is applied. This workflow reminds people to add the label +# because it isn't always obvious. + +name: Chromatic Label Helper + +on: + pull_request: + types: [ready_for_review] + +jobs: + write_comment: + runs-on: ubuntu-latest + permissions: + pull-requests: write + + steps: + - uses: actions/github-script@v7 + with: + script: | + const labels = await github.rest.issues + .listLabelsOnIssue({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + }) + .then(({ data }) => data); + + const hasChromaticLabel = labels.some( + (label) => label.name === 'run-chromatic', + ); + + if (!hasChromaticLabel) { + const commentLines = [ + "Hello :wave:! When you're ready to run Chromatic, please apply the `run_chromatic` label to this PR.", + '[Click here to see the Chromatic project.](https://www.chromatic.com/builds?appId=63e251470cfbe61776b0ef19)', + ]; + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: commentLines.join('\n\n'), + }); + }