Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capture stdout and store as output #287

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

GammaGames
Copy link

@GammaGames GammaGames commented Jan 2, 2024

Possibly fixes #274, #38

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: SSH
        id: ssh
        uses: https://github.com/GammaGames/ssh-action@master
        with:
          host: [fill in]
          script: |
            ls -l ~/test/
      - name: echo
        run: echo "${{ steps.ssh.outputs.stdout }}"

If successful, it has the following in steps.ssh.outputs.stdout:

======CMD======
ls -l ~/test/
======END======
out: total 0
out: -rw-rw-r-- 1 user group 0 Jan  2 14:24 file1
out: -rw-rw-r-- 1 user group 0 Jan  2 14:24 file2
==============================================
✅ Successfully executed commands to all host.
==============================================

On error it acts like it does now.

@GammaGames
Copy link
Author

One potential issue is that secrets aren't masked in the output variable like they are in the log. I was able to fix it with a filtering step, but it's manual:

- uses: mad9000/actions-find-and-replace-string@4
  id: filter
  with:
    source: ${{ steps.ssh.outputs.stdout }}
    find: '${{ secrets.value }}'
    replace: '***'
    replaceAll: true
- run: echo '${{ steps.filter.outputs.value }}'

@GammaGames
Copy link
Author

GammaGames commented Apr 3, 2024

fixed conflicts

edit: fixed conflicts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Example of how to use this and get output of one or more lines to $GITHUB_OUTPUT
1 participant