mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-22 18:17:39 +08:00
Explicitly check permissions when receiving a slash command
This commit is contained in:
parent
f6d2c59bca
commit
e3faacd160
31
.github/workflows/bench-pr.yml
vendored
31
.github/workflows/bench-pr.yml
vendored
@ -16,6 +16,37 @@ jobs:
|
|||||||
runs-on: benchmarks
|
runs-on: benchmarks
|
||||||
timeout-minutes: 180 # 3h
|
timeout-minutes: 180 # 3h
|
||||||
steps:
|
steps:
|
||||||
|
- name: Check permissions
|
||||||
|
id: permission
|
||||||
|
env:
|
||||||
|
PR_AUTHOR: ${{github.event.issue.user.login }}
|
||||||
|
COMMENT_AUTHOR: ${{github.event.comment.user.login }}
|
||||||
|
REPOSITORY: ${{github.repository}}
|
||||||
|
PR_ID: ${{github.event.issue.number}}
|
||||||
|
run: |
|
||||||
|
PR_REPOSITORY=$(gh api /repos/"$REPOSITORY"/pulls/"$PR_ID" --jq .head.repo.full_name)
|
||||||
|
if $(gh api /repos/"$REPOSITORY"/collaborators/"$PR_AUTHOR"/permission --jq .user.permissions.push)
|
||||||
|
then
|
||||||
|
echo "::notice title=Authentication success::PR author authenticated"
|
||||||
|
else
|
||||||
|
echo "::error title=Authentication error::PR author doesn't have push permission on this repository"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if $(gh api /repos/"$REPOSITORY"/collaborators/"$COMMENT_AUTHOR"/permission --jq .user.permissions.push)
|
||||||
|
then
|
||||||
|
echo "::notice title=Authentication success::Comment author authenticated"
|
||||||
|
else
|
||||||
|
echo "::error title=Authentication error::Comment author doesn't have push permission on this repository"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ "$PR_REPOSITORY" = "$REPOSITORY" ]
|
||||||
|
then
|
||||||
|
echo "::notice title=Authentication success::PR started from main repository"
|
||||||
|
else
|
||||||
|
echo "::error title=Authentication error::PR started from a fork"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Check for Command
|
- name: Check for Command
|
||||||
id: command
|
id: command
|
||||||
uses: xt0rted/slash-command-action@v2
|
uses: xt0rted/slash-command-action@v2
|
||||||
|
31
.github/workflows/benchmarks-pr.yml
vendored
31
.github/workflows/benchmarks-pr.yml
vendored
@ -13,6 +13,37 @@ jobs:
|
|||||||
runs-on: benchmarks
|
runs-on: benchmarks
|
||||||
timeout-minutes: 4320 # 72h
|
timeout-minutes: 4320 # 72h
|
||||||
steps:
|
steps:
|
||||||
|
- name: Check permissions
|
||||||
|
id: permission
|
||||||
|
env:
|
||||||
|
PR_AUTHOR: ${{github.event.issue.user.login }}
|
||||||
|
COMMENT_AUTHOR: ${{github.event.comment.user.login }}
|
||||||
|
REPOSITORY: ${{github.repository}}
|
||||||
|
PR_ID: ${{github.event.issue.number}}
|
||||||
|
run: |
|
||||||
|
PR_REPOSITORY=$(gh api /repos/"$REPOSITORY"/pulls/"$PR_ID" --jq .head.repo.full_name)
|
||||||
|
if $(gh api /repos/"$REPOSITORY"/collaborators/"$PR_AUTHOR"/permission --jq .user.permissions.push)
|
||||||
|
then
|
||||||
|
echo "::notice title=Authentication success::PR author authenticated"
|
||||||
|
else
|
||||||
|
echo "::error title=Authentication error::PR author doesn't have push permission on this repository"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if $(gh api /repos/"$REPOSITORY"/collaborators/"$COMMENT_AUTHOR"/permission --jq .user.permissions.push)
|
||||||
|
then
|
||||||
|
echo "::notice title=Authentication success::Comment author authenticated"
|
||||||
|
else
|
||||||
|
echo "::error title=Authentication error::Comment author doesn't have push permission on this repository"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ "$PR_REPOSITORY" = "$REPOSITORY" ]
|
||||||
|
then
|
||||||
|
echo "::notice title=Authentication success::PR started from main repository"
|
||||||
|
else
|
||||||
|
echo "::error title=Authentication error::PR started from a fork"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
- uses: helix-editor/rust-toolchain@v1
|
- uses: helix-editor/rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
profile: minimal
|
profile: minimal
|
||||||
|
Loading…
Reference in New Issue
Block a user