Closed svenluijten closed 4 years ago
Thank you for the suggestion. That seems very useful.
If I understand it correctly, this PR only defines the output parameter, and we would still need to set the parameter value to the out put of the dnscontrol
command.
Not tested, but looks like something like this should work:
dnsc_out="$(dnscontrol $*)"
echo "::set-output name=output::${dnsc_out}"
echo "$dnsc_out"
I was under the impression that anything that lands in stdout
will be piped to the output automatically, and ::set-output
(and those other "workflow commands") should only be used in workflows, not in the actions themselves.
From the page you linked:
But as you said, that's completely untested and only based on what I've read in the docs. I will do some testing later today/over the weekend and get back to you actually. This was just a late night idea anyway 😛
I think you are right.
This example seems to confirm that:
https://github.com/actions/cache/blob/b8204782bbb5f872091ecc5eb9cb7d004e35b1fa/action.yml#L14-L16
And then use the output (e.g. steps.restore-cache.outputs.cache-hit
) in a workflow step:
# Re-export dependencies if anything has changed or if it is the first time
- name: Setting dependency cache
run: |
esy export-dependencies
if: steps.restore-cache.outputs.cache-hit != 'true'
Turns out that's enough for Javascript actions, but for Docker ones (like this one), you'd still need to manually set the output parameter in entrypoint.sh
: https://github.com/actions/hello-world-docker-action/blob/b136eb8894c5cb1dd5807da824be97ccdf9b5423/entrypoint.sh 😄
This seems to work now, the output of the dnscontrol
command is piped out to the output
parameter correctly. I'm open to changing the name though, outputs.output
isn't very telling at the moment. 😛
Messed up the git history a bit, but it's good now. You can see it (and its "work in progress" 😅 ) at https://github.com/svenluijten/dns/pull/3.
Thanks for the merge @koenrh! 🎉
Could you also tag a version? 😬 Don't really wanna use @master
for obvious reasons haha. Or did you want to wait for #28? Can I help?
🙌 Thank you!
We'll set an output in the Actions metadata file (link) so users can do something with that output.
My specific usecase was that I want my own GitHub action to comment the diff of
dnscontrol preview
on the PR, instead of having to dig down into the "Checks" tab after every push. I'm open to other names than "output", but I wanted to keep it nice and generic, as "diff" wouldn't be suitable for commands likednscontrol push
orcheck
.