Skip to content

Commit d060ba6

Browse files
committed
only require approvals on PRs from forks
1 parent 945d310 commit d060ba6

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

.github/workflows/test-warehouse.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,25 @@ env:
5353
TESTS_DIR: ${{ github.workspace }}/dbt-data-reliability/integration_tests
5454

5555
jobs:
56+
detect-fork:
57+
runs-on: ubuntu-latest
58+
outputs:
59+
requires_approval: ${{ steps.set-output.outputs.requires_approval }}
60+
steps:
61+
- name: Set fork output
62+
id: set-output
63+
run: |
64+
if [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]]; then
65+
echo "requires_approval=true" >> $GITHUB_OUTPUT
66+
else
67+
echo "requires_approval=false" >> $GITHUB_OUTPUT
68+
fi
69+
5670
test:
5771
runs-on: ubuntu-latest
58-
environment: elementary_test_env # This is a github environment (not to be confused with env vars)
72+
needs: [detect-fork]
73+
# PRs from forks require approval - so we use an environment that requires an approver from the team.
74+
environment: ${{ (steps.detect-fork.outputs.requires_approval == 'true' && 'elementary_test_env') || '' }}
5975
concurrency:
6076
# This is what eventually defines the schema name in the data platform.
6177
group: tests_${{ inputs.warehouse-type }}_dbt_${{ inputs.dbt-version }}_${{ github.head_ref || github.ref_name }}

0 commit comments

Comments
 (0)