1111jobs :
1212 topological-sort-optimization :
1313 # Dynamically determine if environment is needed only when workflow files change and contributor is external
14- environment : ${{
15- github.event_name == 'workflow_dispatch' ||
16- contains(toJSON(github.event.pull_request.files.*.filename), '.github/workflows/') &&
17- github.event.pull_request.user.login != 'misrasaurabh1' &&
18- github.event.pull_request.user.login != 'KRRT7'
19- ? 'external-trusted-contributors' : ' '
20- }}
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' || '' }}
2115 runs-on : ubuntu-latest
2216 env :
2317 CODEFLASH_AIS_SERVER : prod
@@ -33,11 +27,38 @@ jobs:
3327 with :
3428 fetch-depth : 0
3529 token : ${{ secrets.GITHUB_TOKEN }}
30+ - name : Debug Environment Decision
31+ run : |
32+ # Construct the condition result manually for debugging
33+ EVENT_NAME="${{ github.event_name }}"
34+ FILES_CHANGED="${{ toJSON(github.event.pull_request.files.*.filename) }}"
35+ PR_AUTHOR="${{ github.event.pull_request.user.login }}"
36+
37+ echo "Event Name: $EVENT_NAME"
38+ echo "Files Changed: $FILES_CHANGED"
39+ echo "PR Author: $PR_AUTHOR"
40+
41+ # Check workflow file changes
42+ if [[ "$FILES_CHANGED" == *".github/workflows/"* ]]; then
43+ echo "Workflow files changed: YES"
44+ else
45+ echo "Workflow files changed: NO"
46+ fi
47+
48+ # Check author conditions
49+ if [[ "$PR_AUTHOR" != "misrasaurabh1" && "$PR_AUTHOR" != "KRRT7" ]]; then
50+ echo "Author needs approval: YES"
51+ else
52+ echo "Author needs approval: NO"
53+ fi
54+
55+ # Selected environment
56+ echo "Selected 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' || '' }}"
3657
3758 - name : Validate PR for workflow changes
3859 run : |
3960 # Check for any workflow changes
40- if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then
61+ if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head. sha }}" | grep -q "^.github/workflows/"; then
4162 echo "⚠️ Workflow changes detected."
4263 # Get the PR author
4364 AUTHOR="${{ github.event.pull_request.user.login }}"
0 commit comments