diff --git a/.drone.yml b/.drone.yml index 76a489dd7..0f6b1571d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -48,8 +48,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 diff --git a/tests/check-org-membership.sh b/tests/check-org-membership.sh new file mode 100755 index 000000000..1a4471384 --- /dev/null +++ b/tests/check-org-membership.sh @@ -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 diff --git a/tests/pass-rate.sh b/tests/pass-rate.sh index 2996e89dc..11f1f0024 100755 --- a/tests/pass-rate.sh +++ b/tests/pass-rate.sh @@ -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-product/commits?access_token=$GITHUB_AUTOMATION_API_KEY | jq -r ".[].sha" | xargs -n1 -I{} curl -s https://api.github.com/repos/vmware/vic-product/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-product/commits | jq -r ".[].sha" | xargs -n1 -I{} curl -s -H "Authorization: token $GITHUB_AUTOMATION_API_KEY" https://api.github.com/repos/vmware/vic-product/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"