Skip to content

Instantly share code, notes, and snippets.

@weibeld
Created August 2, 2020 11:25
Show Gist options
  • Save weibeld/b8db6a1201ca54d33d6b35147a0c5509 to your computer and use it in GitHub Desktop.
Save weibeld/b8db6a1201ca54d33d6b35147a0c5509 to your computer and use it in GitHub Desktop.
GitHub Actions example workflow — Outputs 2
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 }}"
@phanirithvij2000
Copy link

For anyone seeing this,
this echo "::set-output ..." syntax won't work when run from inside a script
example :

# sample.sh
echo "::set-output name=ip-address::$(curl -s ifconfig.me)"
# workflow
  steps:
      - name: step-1
        id: xyz
        run: source sample.sh
      - name: step-2
        run: echo "${{ steps.xyz.outputs.ip-address }}"

This will fail to ::set-output

@stardustman
Copy link

is there a way to solve it?

@mraarif
Copy link

mraarif commented Nov 15, 2021

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 }}

@vorporeal
Copy link

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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment