Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rajhawaldar/e5514b2d4d1509c769374c30f04ed632 to your computer and use it in GitHub Desktop.
Save rajhawaldar/e5514b2d4d1509c769374c30f04ed632 to your computer and use it in GitHub Desktop.
Convert GitHub workflow inputs to ENV variables
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