Amadevus / pwsh-script

GitHub Action to run PowerShell scripts in a rich, prepared scope - inspired by actions/github-script.
MIT License
47 stars 8 forks source link

Set-ActionOutput not setting any output #11

Closed MolotovCherry closed 3 years ago

MolotovCherry commented 3 years ago

Hi,

The Set-ActionOutput cmdlet seems to not be working for me at all. I have this workflow, and when it gets to the next step the output isn't even there.

name: Test

on:
  workflow_dispatch:

jobs:
  build:
    runs-on: windows-latest

    steps:
      - uses: actions/checkout@v2

      - name: Set output
        id: test
        uses: Amadevus/pwsh-script@v2
        with:
          script: |
            Set-ActionOutput testout igottest

      - name: Run a multi-line script
        run: |
          echo "${{ steps.test.outputs.testout }}"

Thanks for the github action by the way, it's really cool to be able to have all these integrations from within powershell 😄

MolotovCherry commented 3 years ago

For now, just using the run command to run the script and manually outputting commands works for me. Write-Host "::set-output name=test::igottest3"

This'll work as a sufficient workaround for me I guess

function Set-OutputVariable {
    param(
        [string]$Name,
        [string]$Value
    )

    Write-Host "::set-output name=$Name::$Value"
}

Set-OutputVariable test value
amis92 commented 3 years ago

Hi @cherryleafroad. Sadly, as noted (https://github.com/Amadevus/pwsh-script#notes), that specific command doesn't work due to this action being a Composite Action (https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#outputs-for-composite-actions) :(

amis92 commented 3 years ago

Most of this action's value is in simplicity of using the $contexts as PowerShell variables instead of workflow expressions, providing all workflow commands as cmdlets (except that Set-ActionOutput, obviously) and saving output as serialized json.