Github action run
invokes a powershell that returns as below:
Powershell return function:
return "$($psitem.Key)=$($psitem.Value)"
The return is assigned to a github action variable returnvalue
The return contains a list of key=value
pairs separated by ' ' [single spacebar]
I wish to assign each returned key-value
pair as github variable=value and then print it.
I use the below workflow run logic to achieve this:
- name: Powershell to split
run: |
"${{ needs.READ_VARS_FROM_XML.outputs.key_value_x }}" -split " " | ForEach-Object {
echo $_
echo "$_" >> $env:GITHUB_OUTPUT
}
- name: Print single key-value attemp 2
run: |
echo "PORT NUMBER: ${{ env.port }} and {{ port }}"
Output:
Powershell to split
Run "deploy_path=C:\\inetpub\\wwwroot\\tss.qa port=8814 app_name=Signup-qa debug=true deploy_password=password deploy_user=" -split " " | ForEach-Object {
deploy_path=C:\\inetpub\\wwwroot\\tss.qa
port=8814
app_name=Signup-qa
debug=true
deploy_password=password
deploy_user=
Print single key-value attemp 2
Run echo "PORT NUMBER: and {{ port }}"
PORT NUMBER: and {{ port }}
I was expecting Port number 8814
to be printed for variable port
but it doesn’t seem to hold any value.
Update: Post answer as suggested I printed the environment variables
steps:
- name: Print Environment Variables
run: |
Get-ChildItem Env:
Unfortunately, I don't see any of the key=value
i.e port=8814
in the output of environment variables. Please suggest what could be wrong?
Can you please suggest what did I miss?