GitHub Action 相互构建环境变量

xpt*_*xpt 6 environment-variables github-actions

GitHub Action中,如何依次构建环境变量:

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
Run Code Online (Sandbox Code Playgroud)

这可能非常有用,例如,这是来自以下的真实示例Dockerfile

ARG JMETER_VERSION="5.4.2"
ENV JMETER_HOME /opt/apache-jmeter-${JMETER_VERSION}
Run Code Online (Sandbox Code Playgroud)

我知道Dockerfile这不是 GitHub Action,但我只是展示它有用时的原理。

jas*_*ard 0

@xpt 我为此目的构建了一个 github 操作,您可以在其中替换和组合变量和范围到特定环境。也许对您的场景有一些用处 - > https://github.com/jnus/json-variables