11name : end-to-end-test 
22
33on :
4-   pull_request :
4+   #  Use pull_request_target for everything to ensure access to secrets
5+   pull_request_target :
6+     paths :
7+       - ' **'    #  Trigger for all paths
8+ 
59  workflow_dispatch :
610
711jobs :
812  benchmark-bubble-sort-optimization :
13+     #  Dynamically determine if environment is needed only when workflow files change and contributor is external
14+     environment : ${{ (github.event_name == 'workflow_dispatch' || (contains(toJSON(github.event.pull_request.files.*.filename), '.github/workflows/') && github.event.pull_request.user.login != 'misrasaurabh1' && github.event.pull_request.user.login != 'KRRT7')) && 'external-trusted-contributors' || '' }} 
15+ 
916    runs-on : ubuntu-latest 
1017    env :
1118      CODEFLASH_AIS_SERVER : prod 
@@ -17,11 +24,37 @@ jobs:
1724      EXPECTED_IMPROVEMENT_PCT : 5 
1825      CODEFLASH_END_TO_END : 1 
1926    steps :
20-       - uses : actions/checkout@v4 
27+       - name : 🛎️ Checkout 
28+         uses : actions/checkout@v4 
2129        with :
30+           ref : ${{ github.event.pull_request.head.ref }} 
31+           repository : ${{ github.event.pull_request.head.repo.full_name }} 
2232          fetch-depth : 0 
2333          token : ${{ secrets.GITHUB_TOKEN }} 
2434
35+       - name : Validate PR 
36+         run : | 
37+           # Check for any workflow changes 
38+           if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" | grep -q "^.github/workflows/"; then 
39+             echo "⚠️ Workflow changes detected." 
40+ 
41+             # Get the PR author 
42+             AUTHOR="${{ github.event.pull_request.user.login }}" 
43+             echo "PR Author: $AUTHOR" 
44+ 
45+             # Allowlist check 
46+             if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then 
47+               echo "✅ Authorized user ($AUTHOR). Proceeding." 
48+             elif [[ "${{ github.event.pull_request.state }}" == "open" ]]; then 
49+               echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding." 
50+             else 
51+               echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting." 
52+               exit 1 
53+             fi 
54+           else 
55+             echo "✅ No workflow file changes detected. Proceeding." 
56+           fi 
57+ 
2558       - name : Set up Python 3.11 for CLI 
2659        uses : astral-sh/setup-uv@v5 
2760        with :
0 commit comments