GitHub Actions - Getting Started with Output
by
Jeremy Canfield |
Updated: April 15 2024
| GitHub Actions articles
GitHub Actions can be used to do something whenever something happens in one of your GitHub repositories. If you are not familiar with GitHub Actions, check out my article Getting Started with GitHub Actions.
If using a Linux runner, such as Ubuntu, run can be used to issue the echo command to create a variable (foo in this example) with a value (Hello World in this example) and then redirect the output to $GITHUB_OUTPUT.
If you want to use the output in the same job, you would then use steps.<id>.outputs.<variable name> which would be steps.greeting.outputs.foo in this example.
name: GitHub Action (POC)
run-name: ${{ github.workflow }} run by ${{ github.actor }}
on:
workflow_dispatch:
jobs:
poc:
runs-on: ubuntu-latest
steps:
- name: echo Hello World
id: greeting
run: echo "foo=Hello World" >> $GITHUB_OUTPUT
- name: echo foo
run: |
echo ${{ steps.greeting.outputs.foo }}
You can​ also
Did you find this article helpful?
If so, consider buying me a coffee over at