Reputation: 3091
I have a GitHub action that essentially is a bash script. The javascript portion of my action executes a bash script:
const core = require("@actions/core");
const exec = require("@actions/exec");
async function run() {
try {
// Execute bash script
await exec.exec(`${__dirname}/my-action-script.sh`);
} catch (error) {
core.setFailed(error.message);
}
}
run();
For now, this action will communicate with other actions by leaving files on the file system. This is an "invisible" way of communication and I would like to fill my action.yml
with outputs. How can I enable my-action-script.sh
to return me outputs defined in my action.yml
?
Upvotes: 8
Views: 9510
Reputation: 23477
Not totally clear if this is an action in a repo, or something you want to publish to the marketplace. At any rate, creating the output is done in the same way as indicated by the other answer, although you can run directly the shell if you use:
name: some GitHub workflow yaml file
description: some workflow description
runs:
using: composite
main: my-action-script.sh
inputs:
some_input:
description: some input
required: false
outputs:
some_output:
description: some output
See this article on creating this kind of actions
Upvotes: 0
Reputation: 3091
the output must first be added to the action.yml
, ex:
name: some GitHub workflow yaml file
description: some workflow description
runs:
using: node12
main: dist/index.js
inputs:
some_input:
description: some input
required: false
outputs:
some_output:
description: some output
and create the output from the bash script, ex:
echo ::set-output name=some_output::"$SOME_OUTPUT"
then you can use it in your workflow yaml, ex:
${{ steps.<step id>.outputs.some_output }}
Upvotes: 5