mirror of
https://github.com/dani-garcia/bw_web_builds.git
synced 2024-12-27 12:58:15 +03:00
12568dfbb4
Sometimes you want to set specific environment variables during build. For example, on some systems nodejs needs some extra options to be able to run correctly on low memory systems. To make sure this will be loaded and works on both scripts and Dockerfile, you can now create a `.build_env` file. This `.build_env` file should contain all the variables (including an export command) you want to expose during build time. The template file has a nodejs example. Closes #183 Signed-off-by: BlackDex <black.dex@gmail.com>
28 lines
994 B
Bash
28 lines
994 B
Bash
#!/usr/bin/env bash
|
|
# shellcheck disable=SC2034
|
|
set -o pipefail -o errexit
|
|
ENV_BASEDIR=$(RL=$(readlink -n "$0"); SP="${RL:-$0}"; dirname "$(cd "$(dirname "${SP}")"; pwd)/$(basename "${SP}")")
|
|
|
|
VAULT_FOLDER=${VAULT_FOLDER:=web-vault}
|
|
CHECKOUT_TAGS=${CHECKOUT_TAGS:=true}
|
|
OUTPUT_FOLDER=builds
|
|
|
|
function get_web_vault_version {
|
|
# First check if we are able to get a tag or branch
|
|
VAULT_VERSION=$(git describe --abbrev=0 --tags --exact-match 2>/dev/null || git branch --show-current)
|
|
# Else we will use the current commit hash
|
|
if [[ -z "${VAULT_VERSION}" ]]; then
|
|
VAULT_VERSION=$(git rev-parse HEAD)
|
|
fi
|
|
# Remove everything up to the first occurrence of "-"
|
|
# The extracted tag could start with either `web-`, `desktop-`, `cli-` or `browser-`
|
|
echo "${VAULT_VERSION#*-}"
|
|
}
|
|
|
|
# Load build environment variables if it exists
|
|
if [ -f "${ENV_BASEDIR}/../.build_env" ]; then
|
|
# shellcheck source=../.build_env
|
|
. "${ENV_BASEDIR}/../.build_env"
|
|
fi
|
|
|
|
unset ENV_BASEDIR
|