-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
name: Load environment values | ||
description: Load environment values | ||
|
||
inputs: | ||
environment-name: | ||
description: Name of the environment to load | ||
value-set: | ||
description: Name of the value set to load | ||
tool-version: | ||
description: Version of the env-loader tool to use | ||
default: ${{ github.action_ref }} | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Install the tool | ||
shell: bash | ||
env: | ||
TOOL_VERSION: ${{ inputs.tool-version || github.action_ref }} | ||
INSTALL_DIR: /opt/bin | ||
run: | | ||
# Build the download URL | ||
case "${RUNNER_OS}" in | ||
Linux) OS='linux' ;; | ||
Windows) OS='windows' ;; | ||
macOS) OS='darwin' ;; | ||
*) echo "Unsupported runner OS ${RUNNER_OS}" >&2; exit 1 ;; | ||
esac | ||
case "${RUNNER_ARCH}" in | ||
X86) ARCH='x86_64' ;; | ||
X64) ARCH='amd64' ;; | ||
ARM) ARCH='arm' ;; | ||
ARM64) ARCH='arm64' ;; | ||
*) echo "Unsupported runner architecture ${RUNNER_ARCH}" >&2; exit 1 ;; | ||
esac | ||
DOWNLOAD_URL="https://github.com/gravitational/shared-workflows/releases/download/tools/changelog/${TOOL_VERSION}/env-loader-${TOOL_VERSION}-${OS}-${ARCH}.tar.gz" | ||
# Download the tool | ||
DOWNLOAD_DIR="$(mktemp -d -t 'env-loader-' --tmpdir "${RUNNER_TEMP}")" | ||
mkdir -pv "${DOWNLOAD_DIR}" | ||
DOWNLOAD_PATH="${DOWNLOAD_DIR}/env-loader.tar.gz" | ||
echo "Downloading env-loader ${TOOL_VERSION} for ${OS}/${ARCH} from ${DOWNLOAD_URL} to ${DOWNLOAD_PATH}..." | ||
curl -fsSL -o "${DOWNLOAD_PATH}" "${DOWNLOAD_URL}" | ||
echo "Download complete" | ||
# Install the tool | ||
echo "Installing to ${INSTALL_DIR}..." | ||
mkdir -pv "${INSTALL_DIR}" | ||
tar -xzvf "${DOWNLOAD_PATH}" -C "${INSTALL_DIR}" env-loader | ||
echo "${INSTALL_DIR}" >> "${GITHUB_PATH}" | ||
echo "Installation complete!" | ||
# Cleanup | ||
rm -rf "${DOWNLOAD_DIR}" | ||
- name: Load environment values into environment variables | ||
shell: bash | ||
env: | ||
ENV_LOADER_ENVIRONMENT: "${{ inputs.environment-name }}" | ||
ENV_LOADER_VALUE_SET: "${{ inputs.value-set }}" | ||
run: env-loader >> "${GITHUB_ENV}" |