Skip to content

Commit a606171

Browse files
Saga4KRRT7
authored andcommitted
recieve request only when workflow file changed (#137)
1 parent 8375b61 commit a606171

8 files changed

+72
-17
lines changed

.github/workflows/codeflash-optimize.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
name: CodeFlash
22

33
on:
4-
# Use pull_request_target for everything to ensure access to secrets
54
pull_request_target:
65
paths:
76
- '**' # Trigger for all paths
@@ -15,7 +14,14 @@ concurrency:
1514
jobs:
1615
optimize:
1716
name: Optimize new Python code
18-
environment: external-trusted-contributors
17+
# Dynamically determine if environment is needed only when workflow files change and contributor is external
18+
environment: ${{
19+
github.event_name == 'workflow_dispatch' ||
20+
contains(toJSON(github.event.pull_request.files.*.filename), '.github/workflows/') &&
21+
github.event.pull_request.user.login != 'misrasaurabh1' &&
22+
github.event.pull_request.user.login != 'KRRT7'
23+
? 'external-trusted-contributors' : ''
24+
}}
1925
if: ${{ github.actor != 'codeflash-ai[bot]' }}
2026
runs-on: ubuntu-latest
2127
env:
@@ -42,8 +48,8 @@ jobs:
4248
# Allowlist check
4349
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
4450
echo "✅ Authorized user ($AUTHOR). Proceeding."
45-
elif [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.state }}" == "open" ]]; then
46-
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
51+
elif [[ "${{ github.event.pull_request.state }}" == "open" ]]; then
52+
echo "✅ PR is open. Proceeding with appropriate protections."
4753
else
4854
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
4955
exit 1

.github/workflows/end-to-end-test-bubblesort-pytest-no-git.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ on:
1010

1111
jobs:
1212
bubble-sort-optimization-pytest-no-git:
13-
environment: external-trusted-contributors
13+
# 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+
}}
1421
runs-on: ubuntu-latest
1522
env:
1623
CODEFLASH_AIS_SERVER: prod
@@ -39,7 +46,7 @@ jobs:
3946
# Allowlist check
4047
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
4148
echo "✅ Authorized user ($AUTHOR). Proceeding."
42-
elif [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.state }}" == "open" ]]; then
49+
elif [[ "${{ github.event.pull_request.state }}" == "open" ]]; then
4350
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
4451
else
4552
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."

.github/workflows/end-to-end-test-bubblesort-unittest.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ on:
1010

1111
jobs:
1212
bubble-sort-optimization-unittest:
13-
environment: external-trusted-contributors
13+
# 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+
}}
1421
runs-on: ubuntu-latest
1522
env:
1623
CODEFLASH_AIS_SERVER: prod
@@ -39,7 +46,7 @@ jobs:
3946
# Allowlist check
4047
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
4148
echo "✅ Authorized user ($AUTHOR). Proceeding."
42-
elif [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.state }}" == "open" ]]; then
49+
elif [["${{ github.event.pull_request.state }}" == "open" ]]; then
4350
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
4451
else
4552
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."

.github/workflows/end-to-end-test-coverage.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ on:
1010

1111
jobs:
1212
end-to-end-test-coverage:
13-
environment: external-trusted-contributors
13+
# 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+
}}
1421
runs-on: ubuntu-latest
1522
env:
1623
CODEFLASH_AIS_SERVER: prod
@@ -37,7 +44,7 @@ jobs:
3744
# Allowlist check
3845
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
3946
echo "✅ Authorized user ($AUTHOR). Proceeding."
40-
elif [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.state }}" == "open" ]]; then
47+
elif [["${{ github.event.pull_request.state }}" == "open" ]]; then
4148
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
4249
else
4350
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."

.github/workflows/end-to-end-test-futurehouse.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ on:
1010

1111
jobs:
1212
futurehouse-structure:
13-
environment: external-trusted-contributors
13+
# 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+
}}
1421
runs-on: ubuntu-latest
1522
env:
1623
CODEFLASH_AIS_SERVER: prod
@@ -39,7 +46,7 @@ jobs:
3946
# Allowlist check
4047
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
4148
echo "✅ Authorized user ($AUTHOR). Proceeding."
42-
elif [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.state }}" == "open" ]]; then
49+
elif [["${{ github.event.pull_request.state }}" == "open" ]]; then
4350
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
4451
else
4552
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."

.github/workflows/end-to-end-test-init-optim.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@ on:
99

1010
jobs:
1111
init-optimization:
12-
environment: external-trusted-contributors
12+
# Dynamically determine if environment is needed only when workflow files change and contributor is external
13+
environment: ${{
14+
github.event_name == 'workflow_dispatch' ||
15+
contains(toJSON(github.event.pull_request.files.*.filename), '.github/workflows/') &&
16+
github.event.pull_request.user.login != 'misrasaurabh1' &&
17+
github.event.pull_request.user.login != 'KRRT7'
18+
? 'external-trusted-contributors': ''
19+
}}
1320
runs-on: ubuntu-latest
1421
env:
1522
CODEFLASH_AIS_SERVER: prod
@@ -38,7 +45,7 @@ jobs:
3845
# Allowlist check
3946
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
4047
echo "✅ Authorized user ($AUTHOR). Proceeding."
41-
elif [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.state }}" == "open" ]]; then
48+
elif [["${{ github.event.pull_request.state }}" == "open" ]]; then
4249
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
4350
else
4451
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."

.github/workflows/end-to-end-test-tracer-replay.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@ on:
99

1010
jobs:
1111
tracer-replay:
12-
environment: external-trusted-contributors
12+
# Dynamically determine if environment is needed only when workflow files change and contributor is external
13+
environment: ${{
14+
github.event_name == 'workflow_dispatch' ||
15+
contains(toJSON(github.event.pull_request.files.*.filename), '.github/workflows/') &&
16+
github.event.pull_request.user.login != 'misrasaurabh1' &&
17+
github.event.pull_request.user.login != 'KRRT7'
18+
? 'external-trusted-contributors': ''
19+
}}
1320
runs-on: ubuntu-latest
1421
env:
1522
CODEFLASH_AIS_SERVER: prod
@@ -38,7 +45,7 @@ jobs:
3845
# Allowlist check
3946
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
4047
echo "✅ Authorized user ($AUTHOR). Proceeding."
41-
elif [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.state }}" == "open" ]]; then
48+
elif [["${{ github.event.pull_request.state }}" == "open" ]]; then
4249
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
4350
else
4451
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."

.github/workflows/end-to-end-topological-sort-test.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ on:
1010

1111
jobs:
1212
topological-sort-optimization:
13-
environment: external-trusted-contributors
13+
# 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+
}}
1421
runs-on: ubuntu-latest
1522
env:
1623
CODEFLASH_AIS_SERVER: prod

0 commit comments

Comments
 (0)