Last active
September 6, 2023 05:02
-
-
Save rajhawaldar/e5514b2d4d1509c769374c30f04ed632 to your computer and use it in GitHub Desktop.
Convert GitHub workflow inputs to ENV variables
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
name: "Convert workflow inputs to ENV variables Example" | |
on: | |
workflow_dispatch: | |
inputs: | |
stage: | |
description: "stage" | |
type: "string" | |
required: true | |
version: | |
description: "version" | |
required: true | |
jobs: | |
context: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Inputs as environment variable | |
shell: bash | |
run: | | |
SAVEIFS=$IFS | |
echo '${{ toJSON(inputs) }}' | jq -r 'to_entries | map("\(.key)=\(.value|tostring)")| .[]' | while IFS='=' read key value; do | |
echo "${key^^}='$value'" >> $GITHUB_ENV | |
done | |
IFS=$SAVEIFS | |
- name: "Print Environment Variables" | |
run: | | |
echo $STAGE | |
echo $VERSION |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment