From 6ab742089966a446fb1c786c0a1f50aa823dd83a Mon Sep 17 00:00:00 2001 From: Benjamin Rasmussen Date: Tue, 28 May 2024 09:20:01 +0200 Subject: [PATCH] Update Chromatic deployment action, to only deploy when needed. Refactored the Chromatic deployment GitHub Action to enhance deployment efficiency by ensuring actions only run when necessary. Up until now, it triggered on every single push, regardless if the push was made against an active pull request or not. The workflow now triggers on push events for the main, develop, and release/* branches, and on specific pull_request events. Added concurrency control to prevent duplicate workflows from running simultaneously by canceling in-progress actions if a new relevant event occurs. These changes improve deployment efficiency, consistency, and hopefully means we won't exceed the tokens as often. --- .github/workflows/chromatic.yml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/chromatic.yml b/.github/workflows/chromatic.yml index 26505dd21..51cfcd6bf 100644 --- a/.github/workflows/chromatic.yml +++ b/.github/workflows/chromatic.yml @@ -1,6 +1,21 @@ -name: "Chromatic" +name: 'Chromatic' + +on: + push: + branches: + # Required for creating baselines + - main + - develop + - release/* + pull_request: + types: [ready_for_review, opened, synchronize] + +# Detect if this action is already running, and cancel it. +# This most likely happened because a second push has been made to a branch. +concurrency: + group: ${{ github.repository_id }}-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true -on: push jobs: chromatic-deployment: runs-on: ubuntu-latest