Skip to content

Commit

Permalink
Fixed to access github api error (#708)
Browse files Browse the repository at this point in the history
  • Loading branch information
ading007 authored Jun 16, 2021
1 parent 80c3790 commit bde6843
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
3 changes: 1 addition & 2 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ pipeline:
secrets:
- github_automation_api_key
commands:
- echo ${DRONE_COMMIT_AUTHOR}
- /bin/bash -c '[[ ! $(curl --silent "https://api.github.com/orgs/vmware/members/${DRONE_COMMIT_AUTHOR}?access_token=$GITHUB_AUTOMATION_API_KEY") ]]'
- tests/check-org-membership.sh
when:
status: success

Expand Down
26 changes: 26 additions & 0 deletions tests/check-org-membership.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
# Copyright 2020-2021 VMware, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

set -ex

echo ${DRONE_COMMIT_AUTHOR}

if [ ! $(curl --silent -H "Authorization: token $GITHUB_AUTOMATION_API_KEY" "https://api.github.com/orgs/vmware/members/${DRONE_COMMIT_AUTHOR}") ]; then
echo "checked origin membership successfully"
else
echo "failed to check origin membership"
exit 1
fi
2 changes: 1 addition & 1 deletion tests/pass-rate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

curl -s https://api.github.com/repos/vmware/vic-ui/commits?access_token=$GITHUB_AUTOMATION_API_KEY | jq -r ".[].sha" | xargs -n1 -I{} curl -s https://api.github.com/repos/vmware/vic-ui/statuses/{}?access_token=$GITHUB_AUTOMATION_API_KEY | jq -r ".[-0].state" > status.out
curl -s -H "Authorization: token $GITHUB_AUTOMATION_API_KEY" https://api.github.com/repos/vmware/vic-ui/commits | jq -r ".[].sha" | xargs -n1 -I{} curl -s -H "Authorization: token $GITHUB_AUTOMATION_API_KEY" https://api.github.com/repos/vmware/vic-ui/statuses/{} | jq -r ".[-0].state" > status.out

failures=$(cat status.out | grep -c failure)
echo "Number of failed merges to master in the last 30 merges: $failures"
Expand Down

0 comments on commit bde6843

Please sign in to comment.