I am building my own Github-actions repository. I am trying to use the output of an action in the following step, but I could not manage to do so.
This is a minimal example with what I want to do:
I have an action that do some stuff and stores an output value (boolean for instance). The minimum action.yml would be like this:
# action_with_output/action.yml
name: action_with_output
outputs:
out:
description: 'Some output'
runs:
using: composite
steps:
- name: action with output step
shell: bash
run: echo "out=true" >> $GITHUB_OUTPUT
Then, in my workflow I want to use such output called out. Like this:
# .github/workflows/my_workflow.yml
...
workflow_name:
runs-on: ubuntu-22.04
steps:
- name: Sync repository
uses: actions/checkout@v3
with:
path: src
- name: Run some action with output
uses: ./src/action_with_output
id: step1
- name: Read output
run: echo "${{ steps.step1.outputs.out }}"
I would expect the output of step Read output to be true, but instead I do not get any output, as if the output variable never existed.
You can see some test cases in this PR: https://github.com/eProsima/eProsima-CI/actions/runs/4945870294/jobs/8843185789?pr=26
It works if I try the same but instead of calling the action action_with_output, I use this step:
- name: Run some action with output
run: echo "out=true" >> $GITHUB_OUTPUT
id: step1
Okey, I just figured out what I missed with this answer: https://stackoverflow.com/a/64471887/17049427
I have to explicitly specify the value of each output variable as follows: