Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run Chromatic on correct ref, require approval before running pull_request_target actions #2722

Merged
merged 20 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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