Skip to content

Commit

Permalink
moved deploy func to util
Browse files Browse the repository at this point in the history
  • Loading branch information
jloleysens committed Oct 28, 2024
1 parent e872694 commit f072a3e
Showing 1 changed file with 1 addition and 28 deletions.
29 changes: 1 addition & 28 deletions .buildkite/scripts/steps/publish_oas_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,10 @@
set -euo pipefail

source .buildkite/scripts/common/util.sh

## Install the bump CLI for just this step
npm install -g bump-cli@^2.8.2
source .buildkite/scripts/serverless/publish_oas/publish_oas_utils.sh

echo "--- Publish OAS docs"

deploy_to_bump() {
local file_path="${1:-}"
local doc_name="${2:-}"
local doc_token="${3:-}"
local branch="${4:-}"

echo "Checking diff for doc '$doc_name' against file '$file_path'..."
local result=$(bump diff $file_path --doc $doc_name --token $doc_token --branch $branch --format=json)
## Bump.sh does not respond with JSON when the diff is empty so we need to handle possibly not JSON :'(
local change_count=$(tr '\n' ' '<<<$result | jq -R 'fromjson? | length')
if [[ ! -z $change_count && $change_count -gt 0 ]]; then
echo "Found $change_count changes..."
echo "About to deploy file '$file_path' to doc '$doc_name' on bump.sh..."
bump deploy $file_path \
--branch $branch \
--doc $doc_name \
--token $doc_token ;
echo ""
echo "Note: if there is a warning of unchanged docs we probably have unpublished deployments waiting."
echo "Go to https://bump.sh/elastic/dashboard to see all the docs in the hub."
else
echo "Did not detect changes for '$file_path'; not deploying. Got response: $result"
fi
}

if [[ "$BUILDKITE_BRANCH" == "main" ]]; then
BUMP_KIBANA_DOC_NAME="$(vault_get kibana-bump-sh kibana-doc-name)"
BUMP_KIBANA_DOC_TOKEN="$(vault_get kibana-bump-sh kibana-token)"
Expand Down

0 comments on commit f072a3e

Please sign in to comment.