Skip to content

Commit

Permalink
Added action for env-loader
Browse files Browse the repository at this point in the history
  • Loading branch information
fheinecke committed Nov 4, 2024
1 parent ff09e6b commit d69f662
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions tools/env-loader/action.yaml
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}"

0 comments on commit d69f662

Please sign in to comment.