Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create outputs on GitHub actions from bash scripts?

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?

like image 582
jactor-rises Avatar asked Jun 30 '26 01:06

jactor-rises


1 Answers

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 }}
like image 97
jactor-rises Avatar answered Jul 02 '26 07:07

jactor-rises



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!