My main workflow mainjob1
calls a reusable workflow reusable_workflow_job
and then proceeds to execute its mainjob2
Workflow level variable XML_PATH
is passed to and used by reusable workflow which generates a variable $returnvalue" i.e. app_name=myapp1
by calling a powershell getXMLkey-value.ps1
and is set to GITHUB_OUTPUT using echo "$returnvalue" >> $env:GITHUB_OUTPUT
.
Inside the reusable workflow the App Name in reusable workflow: ${{ steps.run-scriptsx.outputs.app_name }}"
is printed successfully as App Name in reusable workflow: myapp1
The flow then returns to main workflow mainjob2
where I wish to now print the same app_name
i.e myapp1 but it does not print anything here: echo "App name in mainjob2: ${{ needs.reusuable_workflow_job.outputs.app_name }}"
How can I print app_name
as myapp1
in main workflow's mainjob2
?
Below are my workflow files:
Main workflow file:
env:
XML_PATH: "\\\\remotehost7\\$D\\Logs\\test.xml"
on:
push: main
jobs:
mainjob1:
runs-on: "mylocal_windows"
outputs:
userxmlpath: ${{ steps.step1.outputs.userxmlpath }}
steps:
- name: Print variable
id: step1
run: |
echo "user XML path: ${{ env.XML_PATH }}"
echo "userxmlpath=${{ env.XML_PATH }}">> $env:GITHUB_OUTPUT
reusuable_workflow_job:
needs:
- mainjob1
uses: knowyrtech/betech/.github/workflows/getvalue.yml@mm365
with:
xml_Path: "${{ needs.mainjob1.outputs.userxmlpath }}"
secrets: inherit
mainjob2:
needs:
- reusuable_workflow_job
runs-on: "mylocal_windows"
steps:
- name: Back to main workflow
run: |
echo "App name in mainjob2: ${{ needs.reusuable_workflow_job.outputs.app_name }}"
Reusable workflow:
name: Read XML
on:
workflow_call:
inputs:
xml_Path:
required: true
default: '\\remotehost5\$D\Logs\test.xml'
jobs:
Extract-keys:
runs-on: "mylocal_windows"
steps:
- name: Checkout reusable repo
uses: actions/checkout@v3
with:
repository: knowyrtech/betech
ref: mm365
path: "${{ github.workspace }}/betech"
token: ${{ secrets.my_automated_token }}
- name: Call powershell
id: run-scriptsx
run: |
set-location "${{ github.workspace}}\betech\scripts"
$returnvalue=& "./getXMLkey-value.ps1"
echo "$returnvalue"
echo "$returnvalue" >> $env:GITHUB_OUTPUT
- name: Inside reusable workflow
run: |
echo "App Name in reusable workflow: ${{ steps.run-scriptsx.outputs.app_name }}"