From 898157a2d32c0a44813e661fd4194ff02c138952 Mon Sep 17 00:00:00 2001 From: Sixian Yi Date: Thu, 23 Jan 2025 14:27:39 -0800 Subject: [PATCH] test permission --- .github/CODEOWNERS | 2 +- .github/workflows/tests.yml | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index ecfaf3ec27..1623d1829b 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -2,4 +2,4 @@ # These owners will be the default owners for everything in # the repo. Unless a later match takes precedence, -* @ashwinb @yanxi0830 @hardikjshah @dltn @raghotham @dineshyv @vladimirivic @sixianyi0721 +* @ashwinb @yanxi0830 @hardikjshah @dltn @raghotham @dineshyv @vladimirivic diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ff13a4cb02..3cdab86a74 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,7 +1,7 @@ name: auto-tests on: - # pull_request: + pull_request: workflow_dispatch: inputs: commit_sha: @@ -20,6 +20,17 @@ jobs: matrix: provider: [fireworks, together] steps: + - name: Check user permission + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + CODEOWNERS=$(gh api /repos/${{ github.repository }}/codeowners | jq -r '.owners[]') + + if [[ ! " ${CODEOWNERS[@]} " =~ " ${{ github.actor }} " ]]; then + echo "Only codeowners can trigger this workflow ${{ github.actor }} ${CODEOWNERS[@]}" + exit 1 + fi + - uses: actions/checkout@v4 with: ref: ${{ github.event.inputs.commit_sha }}