I have a powershell that returns key=value
like the below:
cat C:\Logs\getallkey.ps1
Write-Host "app_name=Signup-qa"
Here is the github actions:
- name: Sample append to OUT
id: sample
run: |
echo "app_name_sample=worksss" >> $env:GITHUB_OUTPUT
- name: Use sample script output
run: |
echo "Sample Application_Name: ${{ steps.sample.outputs.app_name_sample }}"
- name: Run PowerShell script
id: run-script
run: |
& "C:\Logs\getallkey.ps1"
- name: Assign to variable
id: run-scriptx
run: |
$returnvalue=& "C:\Logs\getallkey.ps1"
echo "$returnvalue" >> $GITHUB_OUTPUT
- name: Use script output
run: |
echo "Application Name: ${{ steps.run-scriptx.outputs.app_name }}"
See output below:
As evident from the output, Use sample script output
step worked when similar step Use script output
did not print the output. The below is printed in steps Assign to variable
app_name=Signup-qa
However, the same is not being set and printed for step Use script output
which I tried to by means of echo "$returnvalue" >> $GITHUB_OUTPUT
which I thought should have translated to echo "app_name=Signup-qa" >> $GITHUB_OUTPUT
and thus should have printed for step Use script output
as desired output, however it does not:
Application Name: Signup-qa
I also tried the below but it too did not help.
- name: Assign to variable
id: run-scriptx
run: |
$returnvalue=& "C:\Logs\getallkey.ps1"
echo "$returnvalue" >> $env:GITHUB_OUTPUT
Can you please assist?