From 931029e0bdab2d4b320d9b571a6680e056b3f8ab Mon Sep 17 00:00:00 2001 From: Nemanja Glumac <31325167+nemanjaglumac@users.noreply.github.com> Date: Tue, 14 Nov 2023 14:02:33 +0100 Subject: [PATCH] Make Chromatic workflow 3rd party friendly (#35708) --- .github/workflows/chromatic.yml | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/chromatic.yml b/.github/workflows/chromatic.yml index 187dc914cc0..17be43fd636 100644 --- a/.github/workflows/chromatic.yml +++ b/.github/workflows/chromatic.yml @@ -6,12 +6,27 @@ on: - "master" pull_request: types: [synchronize, labeled, unlabeled] + workflow_run: + workflows: [External Trigger Filter] + types: [completed] concurrency: group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }} cancel-in-progress: true jobs: + external-filter: + if: github.event.pull_request.head.repo.full_name == github.repository || github.event.workflow_run.conclusion == 'success' + runs-on: ubuntu-22.04 + timeout-minutes: 3 + steps: + - run: | + if ${{ github.event.pull_request.head.repo.full_name == github.repository }}; then + echo 'Running Chromatic workflow within the organization.' + elif ${{ github.event.workflow_run.conclusion == 'success' }}; then + echo "Running Chromatic workflow for the external contributor. Thank you!" + fi + files-changed: name: Check which files changed runs-on: ubuntu-22.04 @@ -29,8 +44,10 @@ jobs: filters: .github/file-paths.yaml fe-chromatic: - needs: files-changed - if: contains(github.event.pull_request.labels.*.name, 'chromatic') || (github.ref_name == 'master' && needs.files-changed.outputs.frontend_all == 'true') + needs: [files-changed, external-filter] + if: | + (needs.external-filter.result == 'success' && contains(github.event.pull_request.labels.*.name, 'chromatic')) || + (github.ref_name == 'master' && needs.files-changed.outputs.frontend_all == 'true') runs-on: ubuntu-22.04 steps: - name: Checkout repository -- GitLab