Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 23 additions & 10 deletions .github/workflows/uptest-trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,32 @@ env:
GO_VERSION: "1.23"

jobs:
debug:
check-permissions:
runs-on: ubuntu-latest
outputs:
permission: ${{ steps.check-permissions.outputs.permission }}
steps:
- name: Debug
- name: Get Commenter Permissions
id: check-permissions
run: |
echo "Trigger keyword: '/test-examples'"
echo "Go version: ${{ env.GO_VERSION }}"
echo "github.event.comment.author_association: ${{ github.event.comment.author_association }}"

REPO=${{ github.repository }}
COMMENTER=${{ github.event.comment.user.login }}

# Fetch the commenter's repo-level permission grant
GRANTED=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/$REPO/collaborators/$COMMENTER/permission" | jq -r .permission)

# Make it accessible in the workflow via a job output -- cannot use env
echo "User $COMMENTER has $GRANTED permissions"
echo "permission=$GRANTED" >> "$GITHUB_OUTPUT"

get-example-list:
if: ${{ (github.event.comment.author_association == 'OWNER' ) &&
github.event.issue.pull_request &&
contains(github.event.comment.body, '/test-examples' ) }}
needs: check-permissions
if: ${{ (needs.check-permissions.outputs.permission == 'admin' || needs.check-permissions.outputs.permission == 'write') && github.event.issue.pull_request != null && contains(github.event.comment.body, '/test-examples')}}
runs-on: ubuntu-latest
outputs:
example_list: ${{ steps.get-example-list-name.outputs.example-list }}
Expand Down Expand Up @@ -79,11 +92,11 @@ jobs:
-f context="Uptest-${{ steps.get-example-list-name.outputs.example-hash }}"

uptest:
if: ${{ (github.event.comment.author_association == 'OWNER' ) &&
github.event.issue.pull_request &&
contains(github.event.comment.body, '/test-examples' ) }}
needs:
- check-permissions
- get-example-list
if: ${{ (needs.check-permissions.outputs.permission == 'admin' || needs.check-permissions.outputs.permission == 'write') && github.event.issue.pull_request != null && contains(github.event.comment.body, '/test-examples')}}
runs-on: ubuntu-latest
needs: get-example-list

steps:
- name: Cleanup Disk
Expand Down
Loading