GitHub Actions - Getting Started with Output

by
Jeremy Canfield |
Updated: April 14 2025
| 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 }}
If you want to run a command in the runner VM, you can use the following syntax.
name: GitHub Action (POC)
run-name: ${{ github.workflow }} run by ${{ github.actor }}
on:
workflow_dispatch:
jobs:
poc:
runs-on: ubuntu-latest
steps:
- name: get command response
id: command
run: response=$(curl --silent --output /dev/null --write-out "%{http_code}" https://www.example.com/); echo "response=$response" >> $GITHUB_OUTPUT
- name: echo command response
run: echo ${{ steps.command.outputs.response}}
You can​ also
Did you find this article helpful?
If so, consider buying me a coffee over at