Harded code value app_name
was here and it worked fine -> app_namexx: ${{ steps.run-script.outputs.app_name }}
I now wish to replace hard coded app_name
to input variable key_name
. So, Tried the below but I get error:
name: CALLER main yml
on:
push:
branches: main
workflow_dispatch:
inputs:
key_name:
required: true
default: 'app_name'
jobs:
mainjob1:
runs-on: "windows-latest"
outputs:
app_namexx: ${{ steps.run-script.outputs.[key_name] }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
Error output:
The workflow is not valid. Error from called workflow. Unrecognized named-value: 'key_name'. Located at position 27 with expression: steps.run-script.outputs[key_name]
I tried the following but none of it works:
app_namexx: ${{ steps.run-script.outputs[key_name] }}
app_namexx: ${{ steps.run-script.outputs[$key_name] }}
app_namexx: ${{ steps.run-script.outputs.$key_name }}
app_namexx: ${{ steps.run-script.outputs.${key_name} }}
app_namexx: ${{ steps.run-script.outputs.${ inputs.key_name } }}
The purpose of variabelizing outputs
is every time a new key_name
is passed the reusable workflow will return a different value for that key_name
by parsing an key-value style XML using PowerShell. Below are a few sample snapshots of different key-name
to powershell script and the output returned. If key_name
is blank then it will return all key-value pairs:
Thus, based upon the inputs.key_name
passed by the user or if kept empty the caller workflow should get the value returned by the reusable workflow.
I may have to share a new post when dealing with return value for all key-values returned in case -key_name
is empty ""