Compare commits

...

1 Commits

Author SHA1 Message Date
Aurélien Bombo
100ecf3ee3 gha: Pass repo correctly to validate-ok-to-test
The following test run shows that the OWNER variable wasn't being set
correctly. This is probably because the owner of the Kata repo is an
org, not a user.

https://github.com/kata-containers/kata-containers/actions/runs/15590824845/job/43909182087?pr=11408

Instead, we use the full_name field, which is documented here:

https://docs.github.com/en/rest/repos/repos?apiVersion=2022-11-28#get-a-repository

Signed-off-by: Aurélien Bombo <abombo@microsoft.com>
2025-06-11 13:35:29 -05:00

View File

@@ -2,6 +2,7 @@ name: Validate ok-to-test label
on:
pull_request_target:
# SAFETY: Jobs MUST NOT check out code.
types: [synchronize]
jobs:
@@ -15,16 +16,15 @@ jobs:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
AUTHOR: ${{ github.event.pull_request.user.login }}
OWNER: ${{ github.repository.owner.login }}
REPO: ${{ github.event.repository.name }}
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
FULL_REPO: ${{ github.event.repository.full_name }}
run: |
permission="$(gh api "repos/${OWNER}/${REPO}/collaborators/${AUTHOR}/permission" --jq '.permission')"
echo "User ${AUTHOR} has permission '${permission}'"
permission="$(gh api "repos/${FULL_REPO}/collaborators/${PR_AUTHOR}/permission" --jq '.permission')"
echo "User ${PR_AUTHOR} has permission '${permission}'"
if [[ "${permission}" != "write" && "${permission}" != "admin" ]]; then
echo "Removing 'ok-to-test' label"
gh pr edit "${PR_NUMBER}" --repo "${OWNER}/${REPO}" --remove-label "ok-to-test"
gh pr edit "${PR_NUMBER}" --repo "${FULL_REPO}" --remove-label "ok-to-test"
else
echo "User has label permission - skipping removal"
fi