Skip to content

Is it possible to get outputs from a bash script? #1336

Answered by ChristopherHX
DanForever asked this question in Q&A
Discussion options

You must be logged in to vote

Is this something I can do with github actions?

You can set output from within a shell script, the bash script must be able to print to the stdout so the runner sees the command

is it supported by Act?

Yes

script.sh

echo "::set-output name=test::value"
LOCALVAR="Hello World"
echo "::set-output name=test::$LOCALVAR"

.github/workflows/test.yml

on: push
jobs:
  _:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - run: |
          bash ./script.sh
        id: myscript
        shell: bash
      - run: |
          echo "$SCRIPTOUTPUT"
        shell: bash
        env:
          SCRIPTOUTPUT: "${{ tojson(steps.myscript.outputs) }}"

Sample log:

[test.yml/_] ⭐ Run…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by KnisterPeter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants