Skip to content

Commit

Permalink
Merge pull request #2722 from evidence-dev/ci/fix-chromatic-trigger
Browse files Browse the repository at this point in the history
Run Chromatic on correct ref, require approval before running `pull_request_target` actions
  • Loading branch information
zachstence authored Nov 5, 2024
2 parents e187efa + bb53553 commit af75508
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/chromatic.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
name: 'Chromatic'

on:
push:
pull_request_target:

jobs:
external-pr-action-approval:
uses: ./.github/workflows/external-pr-action-approval.yml
chromatic:
needs: external-pr-action-approval
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- uses: pnpm/[email protected]
with:
version: 8.6.9
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/external-pr-action-approval.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# https://datachain.ai/blog/testing-external-contributions-using-github-actions-secrets

on:
workflow_call:

jobs:
external-pr-action-approval:
name: 'External PR Action Approval'
environment: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository && 'Approval required to run action on external PR' || '' }}
runs-on: ubuntu-latest
steps:
- run: true
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
jobs:
Tests-sources:
runs-on: ${{ matrix.os }}
if: ${{ github.triggering_actor == 'archiewood' || github.triggering_actor == 'mcrascal' || github.triggering_actor == 'ud3sh' || github.triggering_actor == 'hughess' || github.triggering_actor == 'winterhart' || github.triggering_actor == 'itsmebriand' || github.triggering_actor == 'kwongz' || github.triggering_actor == 'zachstence' || github.triggering_actor == 'csjh'}}
needs: ./.github/workflows/external-pr-action-approval.yml
timeout-minutes: 20

# Conditional Strategy logic from https://github.com/orgs/community/discussions/26253#discussioncomment-3250989
Expand Down

0 comments on commit af75508

Please sign in to comment.