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

Add outputs to show result in pull requests #31

Open
robermp opened this issue Oct 21, 2021 · 6 comments
Open

Add outputs to show result in pull requests #31

robermp opened this issue Oct 21, 2021 · 6 comments

Comments

@robermp
Copy link

robermp commented Oct 21, 2021

The stdout of the action is empty, so to see the results in PR some lines are needed:

## Gererate action outputs
echo "::set-output name=err::$res"
command="terrascan scan ${args}"
result=$( $command 2>&1)
result="${result//'%'/'%25'}"
result="${result//$'\n'/'%0A'}"
result="${result//$'\r'/'%0D'}"

echo "::set-output name=result::$result"

With this the in the PR the output of the terrascan can be read like this:

        terrascan_log: "${{ steps.terrascan.outputs.result }}"
        terrascan_err: "${{ steps.terrascan.outputs.err }}"

Using stdout:
2021-10-21 17_13_12-add key rotation by robermp · Pull Request #29 · grupoasv_alz_aws_network and 15

Using log output:
2021-10-21 17_12_22-add key rotation by robermp · Pull Request #29 · grupoasv_alz_aws_network and 15

@elijah
Copy link
Contributor

elijah commented Nov 30, 2021

Hey @robermp we're trying to do something very similar - where did you insert the above code to get the output you wanted? Do you have a PR against this repo that you could make available?

@robermp
Copy link
Author

robermp commented Nov 30, 2021

Hi I insert the code just before these lines inside entrypoint.sh file:

Executing terrascan

echo "Executing terrascan as follows:"
echo "terrascan scan ${args}"
terrascan scan ${args}
res=$?

I cant' do a PR because i'm not contributor

@elijah
Copy link
Contributor

elijah commented Dec 1, 2021

This worked for me. Thank you!

I was also able to use unsplash/comment-on-pr@v1.3.0 to return output to our CI system. Very cool!

@cesar-rodriguez
Copy link

Hi @robermp,

A PR would be much appreciated. You should be able to fork the repo and issue a PR from your fork. I'll create the PR if you can't get to it.

@elijah, do you have an example of how you're using unsplash/comment-on-pr@v1.3.0 with the terrascan-action that you could share?

@elijah
Copy link
Contributor

elijah commented Dec 3, 2021

Like this, to push a comment back to the PR:

  • name: comment PR for results
    id: results
    uses: unsplash/comment-on-pr@v1.3.0
    env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    with:
    msg: "${{ steps.terrascan.outputs.result }}"

@robermp
Copy link
Author

robermp commented Dec 7, 2021

Hi @cesar-rodriguez, i generate the PR:
#39

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

No branches or pull requests

3 participants