-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* ci: skip sonarqube step for PR from form #109 * ci: use fresh AVD from benchmark tests (#157) * refactor: build gradle (#161) * chore: split big sdk/build.gradle to several applied gradle sripts * chore: upload all outputs and reports on benchmark failure * ci: move timeout restoriction to step level and reduce it to 20 * debug: enable artifact upload for success bench * fix: ignore HCaptchaWebViewHelperTest.benchmarkWebViewLoad benchmark * ci: skip sonarqube step for PR from form #109 * ci: migrate to own check-user-permission action * fix: bad prior merge * fix: add value to outputs of check-user-permission action
- Loading branch information
Showing
2 changed files
with
85 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Check User Permission | ||
description: Checks if the user has the required permission level. | ||
|
||
inputs: | ||
token: | ||
description: Secret GitHub API token to use for making API requests. | ||
default: ${{ github.token }} | ||
required: true | ||
require: | ||
description: 'Permission level to check against (admin, write, read)' | ||
default: write | ||
required: true | ||
|
||
outputs: | ||
granted: | ||
description: 'true if the user has the required permission, false otherwise' | ||
value: ${{ steps.check.outputs.granted }} | ||
permission: | ||
description: actual user permission (admin, write, read) | ||
value: ${{ steps.check.outputs.permission }} | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Check user permission | ||
id: check | ||
shell: bash | ||
env: | ||
GITHUB_TOKEN: ${{ inputs.token }} | ||
OWNER: ${{ github.repository_owner }} | ||
REPO: ${{ github.event.repository.name }} | ||
USERNAME: ${{ github.triggering_actor }} | ||
PERMISSION: ${{ inputs.require }} | ||
run: | | ||
# Fetch the collaborator permission level using the GitHub API | ||
response=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ | ||
"https://api.github.com/repos/$OWNER/$REPO/collaborators/$USERNAME/permission") | ||
# Extract the permission level from the JSON response | ||
user_permission=$(echo $response | jq -r '.permission') | ||
echo "permission=${user_permission}" >> $GITHUB_OUTPUT | ||
# Compare the permission level with the required permission | ||
if [[ "$user_permission" == "$PERMISSION" || ( "$user_permission" == "admin" && "$PERMISSION" == "write" ) ]]; then | ||
echo "User has the required permission." | ||
echo "granted=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "User does not have the required permission." | ||
echo "granted=false" >> $GITHUB_OUTPUT | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters