Skip to content
This repository has been archived by the owner on Aug 13, 2022. It is now read-only.

Commit

Permalink
Fix shellcheck warnings, test in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
nchlswhttkr committed May 18, 2021
1 parent 1aa0682 commit 5333129
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .buildkite/pipeline.yml
@@ -1,3 +1,3 @@
steps:
- label: ":partyparrot:"
command: git log -1
- label: ":bash: shellcheck"
command: shellcheck *.sh
14 changes: 6 additions & 8 deletions post-receive.sh
@@ -1,8 +1,6 @@
#!/usr/bin/env bash
set -euo pipefail

# TODO: Check compatability with config file

REPO=$(pwd)
CONFIG="$HOME/.mandarin-duck/mandarin-duck.cfg"
CONFIG_VERSION=$(jq --raw-output ".version // \"\"" "$CONFIG")
Expand All @@ -11,29 +9,29 @@ if [[ $CONFIG_VERSION != 1.* ]]; then
exit 1
fi
BUILDKITE_API_TOKEN=$(jq --raw-output ".buildkite_api_token // \"\"" "$CONFIG")
if [[ $BUILDKITE_API_TOKEN == '' ]]; then
if [[ $BUILDKITE_API_TOKEN == "" ]]; then
echo -e "\033[31mBuildkite API token not set, check your config at $CONFIG\033[0m"
exit 1
fi
BUILDKITE_ORGANIZATION_SLUG=$(jq --raw-output ".buildkite_organization_slug // \"\"" "$CONFIG")
if [[ $BUILDKITE_ORGANIZATION_SLUG == '' ]]; then
if [[ $BUILDKITE_ORGANIZATION_SLUG == "" ]]; then
echo -e "\033[31mBuildkite organization name not set, check your config at $CONFIG\033[0m"
exit 1
fi
BUILDKITE_PIPELINE_SLUG=$(jq --raw-output ".projects[\"$REPO\"].buildkite_pipeline_slug // \"\"" "$CONFIG")
if [[ $BUILDKITE_PIPELINE_SLUG == '' ]]; then
if [[ $BUILDKITE_PIPELINE_SLUG == "" ]]; then
echo -e "\033[31mBuildkite pipeline name not set, check your config at $CONFIG\033[0m"
exit 1
fi

# Hacky way of getting all branch names from list of updated local refs
cut -d ' ' -f 3 | sort | uniq | grep "refs/heads/" | cut -c 12- | while read BRANCH; do
cut -d " " -f 3 | sort | uniq | grep "refs/heads/" | cut -c 12- | while read -r BRANCH; do
echo -e "--- Triggering Buildkite build on \033[32m$BRANCH\033[0m"
echo -n "You can view this build at "
curl --fail --silent -X POST https://api.buildkite.com/v2/organizations/$BUILDKITE_ORGANIZATION_SLUG/pipelines/$BUILDKITE_PIPELINE_SLUG/builds \
curl --fail --silent -X POST "https://api.buildkite.com/v2/organizations/$BUILDKITE_ORGANIZATION_SLUG/pipelines/$BUILDKITE_PIPELINE_SLUG/builds" \
-H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
-d "{
\"commit\": \"HEAD\",
\"branch\": \"$BRANCH\"
}" | jq --raw-output '.web_url'
}" | jq --raw-output ".web_url"
done

0 comments on commit 5333129

Please sign in to comment.