Skip to content

Instantly share code, notes, and snippets.

@rthallisey
Last active January 28, 2020 19:35
Show Gist options
  • Save rthallisey/94b08bba192541fd7c7cb5e8d26c08bb to your computer and use it in GitHub Desktop.
Save rthallisey/94b08bba192541fd7c7cb5e8d26c08bb to your computer and use it in GitHub Desktop.
$PROJECT_ROOT/operator-courier/push.sh
#!/usr/bin/env bash
set -e
PROJECT_ROOT="$(readlink -e $(dirname "$BASH_SOURCE[0]")/../../)"
QUAY_REPOSITORY="${QUAY_REPOSITORY:-$APP_NAME-operator}"
PACKAGE_NAME="${PACKAGE_NAME:-$APP_NAME-operator}"
SOURCE_DIR="${SOURCE_DIR:-/manifests}"
REPO_DIR="${QUAY_REPOSITORY:-$APP_NAME-operator}"
NAMESPACE="${PACKAGE_NAME:-$APP_NAME-operator}"
CONTAINER_CLIENT="${CONTAINER_CLIENT:-podman}"
RELEASE="${RELEASE:-}"
BUNDLES=$(curl -s -X GET https://quay.io/cnr/api/v1/packages/${QUAY_REPOSITORY}/${PACKAGE_NAME} | jq '.[]["release"]' | tr -d '"')
echo "List of published bundles:"
echo -e "\e[1m${BUNDLES}\e[0m"
echo "Set RELEASE to a newer version."
echo "RELEASE:"
read RELEASE
if [ -z "${QUAY_USERNAME}" ]; then
echo "QUAY_USERNAME"
read QUAY_USERNAME
fi
if [ -z "${QUAY_PASSWORD}" ]; then
echo "QUAY_PASSWORD"
read -s QUAY_PASSWORD
fi
echo "getting auth token from Quay"
AUTH_TOKEN=$(/"${PROJECT_ROOT}"/tools/token.sh $QUAY_USERNAME $QUAY_PASSWORD)
echo "pushing bundle"
"${CONTAINER_CLIENT}" run \
-e QUAY_USERNAME="${QUAY_USERNAME}" \
-e QUAY_PASSWORD="${QUAY_PASSWORD}" \
-e QUAY_REPOSITORY="${REPO_DIR}" \
courier-build-container push "${SOURCE_DIR}" "${REPO_DIR}" "${NAMESPACE}" "${RELEASE}" "$AUTH_TOKEN"
echo "bundle pushed"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment