Skip to content

Instantly share code, notes, and snippets.

@christeredvartsen
Created November 29, 2019 07:49
Show Gist options
  • Save christeredvartsen/0b77b01e5e7214343bc98843e5e53e67 to your computer and use it in GitHub Desktop.
Save christeredvartsen/0b77b01e5e7214343bc98843e5e53e67 to your computer and use it in GitHub Desktop.
Use output in a workflow step
<?= sprintf('::set-output name=var::%s', json_encode([
[
'id' => 'bar',
'name' => 'foo',
],
[
'id' => 'bar2',
'name' => 'foo2',
],
]));
name: Use jq on output from step
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Run a command that sets an output with name var
id: do-stuff # This is referred to below when fetching output
run: php action.php
- name: Use jq to process JSON output from above command
run: |
echo '${{ steps.do-stuff.outputs.var }}' | jq '{id: .[].id}'
@kushal-omnius
Copy link

actions.php should look like the below now I guess?:

<?= sprintf('name=var >> $GITHUB_OUTPUT%s', json_encode([ [ 'id' => 'bar', 'name' => 'foo', ], [ 'id' => 'bar2', 'name' => 'foo2', ], ]));

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