Skip to content

Commit f975ec8

Browse files
authored
require approval only for fork PRs (#2004)
1 parent 44f8f8a commit f975ec8

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
@@ -75,9 +75,25 @@ env:
7575
ELMENTARY_INTERNAL_DBT_PKG_DIR: ${{ github.workspace }}/elementary/elementary/monitor/dbt_project
7676

7777
jobs:
78+
# PRs from forks require approval, specifically with the "pull_request_target" event as it contains repo secrets.
79+
check-if-requires-approval:
80+
runs-on: ubuntu-latest
81+
outputs:
82+
requires_approval: ${{ steps.set-output.outputs.requires_approval }}
83+
steps:
84+
- name: Set requires approval output
85+
id: set-output
86+
run: |
87+
if [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]]; then
88+
echo "requires_approval=true" >> $GITHUB_OUTPUT
89+
else
90+
echo "requires_approval=false" >> $GITHUB_OUTPUT
91+
fi
92+
7893
test:
7994
runs-on: ubuntu-latest
80-
environment: elementary_test_env # This is a github environment (not to be confused with env vars)
95+
needs: [check-if-requires-approval]
96+
environment: ${{ (needs.check-if-requires-approval.outputs.requires_approval == 'true' && 'elementary_test_env') || '' }}
8197
defaults:
8298
run:
8399
working-directory: elementary

0 commit comments

Comments
 (0)