In Github actions how can you pass outputs from a local action?

I have a local action at ./.github/actions/test-output

name: test-output
description: tests setting an output
outputs:
  test_output:
    description: the output
runs:
  using: "composite"
  steps:
    - name: test
      shell: bash
      run: |
        echo test_output=hello >> $GITHUB_OUTPUT
        echo "TEST=yellow" >> "$GITHUB_ENV"

I use this in my workflow – along with an “inline action which also sets an output:

name: test
run-name: ${{ github.actor }} is testing GitHub Actions
on:
  push:
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: echo "thiswillwork=avalue" >> $GITHUB_OUTPUT
        id: thisworks
      - uses: ./.github/actions/test-output
        id: test-output
      - name: json
        run: |
          echo $JSON
          echo ${{ env.TEST}}
        env:
          JSON: ${{ toJSON(steps) }}
      

I get the output from my inline action but not the local action 🙁 although I DO get the environment variable it sets:

Run echo $JSON
  echo $JSON
  echo yellow
  shell: /usr/bin/bash -e {0}
  env:
    TEST: yellow
    JSON: {
    "thisworks": {
      "outputs": {
        "thiswillwork": "avalue"
      },
      "outcome": "success",
      "conclusion": "success"
    },
    "test-output": {
      "outputs": {},
      "outcome": "success",
      "conclusion": "success"
    }
  }
{ "thisworks": { "outputs": { "thiswillwork": "avalue" }, "outcome": "success", "conclusion": "success" }, "test-output": { "outputs": {}, "outcome": "success", "conclusion": "success" } }
yellow

see also here: https://github.com/gilesbradshaw/batch-example/actions/runs/6665692659/job/18115801669

it works fine on gitea https://sigyl.com/git/actions/batch-example/actions/runs/292

So how can I pass outputs back from actions?

Leave a Comment