@@ -24,18 +24,20 @@ jobs:
2424 if : ${{ env.SKIP_BENCHMARKS != '1' }}
2525 uses : actions/checkout@v4
2626 with :
27- ref : ${{ github.head_ref }}
27+ repository : ${{ github.event.pull_request.head.repo.full_name }}
28+ ref : ${{ github.event.pull_request.head.ref }}
2829 fetch-depth : 0
2930
3031 - name : Install GitHub CLI
31- if : ${{ env.SKIP_BENCHMARKS != '1' }}
32+ # We disallow skipping benchmarks for PRs from forks to avoid exposing secrets
33+ if : ${{ github.event.pull_request.head.repo.full_name == github.repository && env.SKIP_BENCHMARKS != '1' }}
3234 run : |
3335 sudo apt-get update
3436 sudo apt-get install -y gh
3537 echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
3638
3739 - name : Check skip label
38- if : ${{ env.SKIP_BENCHMARKS != '1' }}
40+ if : ${{ github.event.pull_request.head.repo.full_name == github.repository && env.SKIP_BENCHMARKS != '1' }}
3941 run : |
4042 labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name')
4143 if echo "$labels" | grep -q "skip-validate-benchmarks"; then
5052 sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler
5153
5254 - name : Check skip label
53- if : ${{ env.SKIP_BENCHMARKS != '1' }}
55+ if : ${{ github.event.pull_request.head.repo.full_name == github.repository && env.SKIP_BENCHMARKS != '1' }}
5456 run : |
5557 labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name')
5658 if echo "$labels" | grep -q "skip-validate-benchmarks"; then
6668 toolchain : stable
6769
6870 - name : Check skip label
69- if : ${{ env.SKIP_BENCHMARKS != '1' }}
71+ if : ${{ github.event.pull_request.head.repo.full_name == github.repository && env.SKIP_BENCHMARKS != '1' }}
7072 run : |
7173 labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name')
7274 if echo "$labels" | grep -q "skip-validate-benchmarks"; then
8183 key : bench-${{ hashFiles('**/Cargo.lock') }}
8284
8385 - name : Check skip label
84- if : ${{ env.SKIP_BENCHMARKS != '1' }}
86+ if : ${{ github.event.pull_request.head.repo.full_name == github.repository && env.SKIP_BENCHMARKS != '1' }}
8587 run : |
8688 labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name')
8789 if echo "$labels" | grep -q "skip-validate-benchmarks"; then
9597 cargo build --profile production -p node-subtensor --features runtime-benchmarks
9698
9799 - name : Check skip label
98- if : ${{ env.SKIP_BENCHMARKS != '1' }}
100+ if : ${{ github.event.pull_request.head.repo.full_name == github.repository && env.SKIP_BENCHMARKS != '1' }}
99101 run : |
100102 labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name')
101103 if echo "$labels" | grep -q "skip-validate-benchmarks"; then
@@ -110,7 +112,7 @@ jobs:
110112 ./scripts/benchmark_action.sh
111113
112114 - name : Check skip label after run
113- if : ${{ env.SKIP_BENCHMARKS != '1' }}
115+ if : ${{ github.event.pull_request.head.repo.full_name == github.repository && env.SKIP_BENCHMARKS != '1' }}
114116 run : |
115117 labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name')
116118 if echo "$labels" | grep -q "skip-validate-benchmarks"; then
0 commit comments