GitHub Action to build environment variables from each other

Viewed 1359

In GitHub Action, how to build environment variables one after another:

name: workflow-level-custom-environment-variables

on: [push]
# Here the environment variable is declared in workflow level
env:
    PART1: var1
    PART2: ${PART1}var2
    PUBLICENV: ${PART2} Available for all jobs in this workflow

This can be really useful, for e.g., here is a real-life example from Dockerfile:

ARG JMETER_VERSION="5.4.2"
ENV JMETER_HOME /opt/apache-jmeter-${JMETER_VERSION}

I know Dockerfile is not GitHub Action, but I'm just showing the principle when it can be useful.

1 Answers

@xpt I've build a github action for this purpose where you can subtitute and combine variables and scope to specific environments. Maybe of some use for your scenario -> https://github.com/jnus/json-variables

Related