Skip to content

Commit

Permalink
Revise check org membership
Browse files Browse the repository at this point in the history
Prior test was unnecessarily complex and resulting in
a non-useful message in error case

The automation token can be added into drone using the drone cli:
* drone secret add
or
* login to the drone webui, go to profile->secrets, and update via
the box in the top right

https://ci-vic.vmware.com/vmware/vic/settings/secrets at time of
writing
  • Loading branch information
hickeng committed Dec 5, 2022
1 parent 09940c8 commit 811fe0c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tests/check-org-membership.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ if [ "$SKIP_CHECK_MEMBERSHIP" == "true" ]; then
exit 0
fi

if [ ! $(curl --silent -H "Authorization: token $GITHUB_AUTOMATION_API_KEY" "https://api.github.com/orgs/vmware/members/${DRONE_COMMIT_AUTHOR}") ]; then
# assuming that the logic here is both a successful curl AND no output.
# testing with a bad auth token shows a 0 return code for curl, but json blob with error
# good auth token is just empty response
result=$(curl --silent -H "Authorization: token $GITHUB_AUTOMATION_API_KEY" "https://api.github.com/orgs/vmware/members/${DRONE_COMMIT_AUTHOR}")
if [ "$?" -eq 0 -o -n "$result" ]; then
echo "checked origin membership successfully"
else
echo "failed to check origin membership"
Expand Down

0 comments on commit 811fe0c

Please sign in to comment.