Created
August 2, 2020 11:25
-
-
Save weibeld/b8db6a1201ca54d33d6b35147a0c5509 to your computer and use it in GitHub Desktop.
GitHub Actions example workflow — Outputs 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: outputs-2 | |
on: workflow_dispatch | |
jobs: | |
my-job: | |
runs-on: ubuntu-latest | |
steps: | |
- name: step-1 | |
id: xyz | |
run: echo "::set-output name=ip-address::$(curl -s ifconfig.me)" | |
- name: step-2 | |
run: echo "${{ steps.xyz.outputs.ip-address }}" |
is there a way to solve it?
maybe set the value as an environment variable
run: echo "ip_address=$(curl -s ifconfig.me)" >> $GITHUB_ENV
and access it, anywhere using
run: echo IP Adress is: ${{ env.ip_address }}
For people finding this: "::set-output" does work within a script; you don't have to put it in the action YAML. (It's possible GitHub has changed something since the comment above saying the opposite, but I just tried it and it worked for me.)
"::set-output" is supposed to still work, but its deprecated. Blog post about how to migrate, which is essentially @mraarif's answer above: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For anyone seeing this,
this
echo "::set-output ..."
syntax won't work when run from inside a scriptexample :
This will fail to
::set-output