grafana/packages/grafana-toolkit/docker/grafana-plugin-ci-alpine/scripts/deploy-common.sh
Arve Knudsen 029278faeb
CI: Add Google Cloud SDK to plugin CI Docker images (#27444)
* grafana-plugin-ci-alpine: Upgrading Go,golangci-lint, adding gcloud

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* grafana-plugin-ci: Upgrading Go,golangci-lint, adding gcloud

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* grafana-plugin-ci-alpine: Minor cleanup

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Don't specify depth when cloning Mage

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* grafana-plugin-ci-e2e: Upgrading Go, golangci-lint

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* ci-deploy: Upgrading gcloud

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Update packages/grafana-toolkit/docker/grafana-plugin-ci-alpine/README.md

Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>

* grafana-plugin-ci-alpine: Install Python

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
2020-09-08 15:06:32 +02:00

53 lines
1.3 KiB
Bash
Executable File

#!/bin/sh
##
# Script to deploy a docker image. Must return exit code 0
#
do_exit() {
message="$1"
exit_code="$2"
echo "$message"
exit $exit_code
}
##
# Get file, get's a file, validates the SHA
# @param filename
# @param expected sha value
# @returns 0 if successful, -1 of checksum validation failed.
#
get_file () {
[ -n "$1" ] && url=$1 || do_exit "url required" 1
[ -n "$2" ] && dest=$2 || do_exit "destination required" 2
sha=$3
file=$(basename $dest)
curl -fL "${url}" -o "$dest"
if [ -n "$sha" ]; then
echo "$sha $dest" | sha256sum || do_exit "Checksum validation failed for $file. Exiting" 1
fi
}
untar_file () {
[ -n "$1" ] && src=$1 || do_exit "src required" 1
[ -n "$2" ] && dest=$2 || dest="/usr/local"
tar -C "$dest" -xf "$src" && /bin/rm -rf "$src"
}
##
# WIP: Just started this and not finished.
# The intent it to download a release from a git repo,
# compile, and install
get_latest_release () {
tarsrc=$(curl -sL "https://api.github.com/repos/$1/$2/releases/latest" | jq ".tarball_url" | tr -d '"')
curl -fL -o /tmp/autoretrieved.tar.gz "$tarsrc"
origdir=$PWD
reponame=$(tar zxvf autoretrieved.tar.gz | tail -1 | awk -F / '{print $1}')
cd "/tmp/$reponame"
#perform compile
cd $origdir
}