mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-18 19:36:48 +00:00
You can call it like this:
./script/ci/check_github_status.sh "pending|success"
It will check if the status is pending or success.
26 lines
719 B
Bash
Executable File
26 lines
719 B
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
source "`dirname $0`/includes.sh"
|
|
|
|
OFN_COMMIT=$(get_ofn_commit)
|
|
if [ "$OFN_COMMIT" = 'OFN_COMMIT_NOT_FOUND' ]; then
|
|
OFN_COMMIT=$(git rev-parse $BUILDKITE_COMMIT)
|
|
fi
|
|
|
|
GITHUB_REPO="$(echo $BUILDKITE_REPO | sed 's/git@github.com:\(.*\).git/\1/')"
|
|
GITHUB_API_URL="https://api.github.com/repos/$GITHUB_REPO/commits/$OFN_COMMIT/status"
|
|
|
|
echo "--- Checking environment variables"
|
|
require_env_vars OFN_COMMIT BUILDKITE_REPO
|
|
|
|
echo "--- Checking GitHub status"
|
|
if [ -n "$1" ]; then
|
|
REQUIRED_STATUS="$1"
|
|
else
|
|
REQUIRED_STATUS="success"
|
|
fi
|
|
echo "Require status '$REQUIRED_STATUS'"
|
|
echo "Visiting $GITHUB_API_URL"
|
|
curl -s "$GITHUB_API_URL" | head -n 2 | grep '^ *"state":' | egrep "\"$REQUIRED_STATUS\",\$"
|