act icon indicating copy to clipboard operation
act copied to clipboard

Add support for Job Summaries

Open weineran opened this issue 3 years ago • 7 comments

Act version

act version 0.2.26

Feature description

GitHub Actions recently added a feature called Job Summaries: https://github.blog/2022-05-09-supercharging-github-actions-with-job-summaries/

When I use act to run a GitHub Action that implements Job Summaries, I get this error: Error: Unable to find environment variable for $GITHUB_STEP_SUMMARY. Check if your runtime environment supports job summaries.

I assume it will require some development work for act to support this feature, so I am creating this feature request.

(If, on the contrary, there is a way to make this work simply by manipulating act command line params or some such thing, let me know!)

weineran avatar May 28 '22 00:05 weineran

You could try running act --env GITHUB_STEP_SUMMARY=/var/run/act/summary

How would you expect act to output the markdown summary?

I guess this can be implemented like the existing GITHUB_ENV file command.

ChristopherHX avatar May 29 '22 20:05 ChristopherHX

Using --env instead of -e (providing event path) works for me:

act --env GITHUB_STEP_SUMMARY=/var/run/act/summary

Haven't checked the output file but in my case I'm not interested in the summary output when running it with act. Just wanted to make sure I can run the same workflow without the need to comment out lines referencing the summary.

mbaeuerle avatar Jun 08 '22 08:06 mbaeuerle

I'm not interested in the summary output when running it with act. Just wanted to make sure I can run the same workflow without the need to comment out lines referencing the summary.

Same here.

act --env GITHUB_STEP_SUMMARY=/var/run/act/summary

This does indeed seem to work 🍾 . Although the first time or two I tried it, I got an error about read/write permissions [1]....but now it's working fine, and I'm not sure what I might have done differently 🤷 .

At any rate, I will go ahead and close this feature request.

[1] In case anyone else runs across it, the error message was:

Error: Unable to access summary file: '/var/run/act/summary'. Check if the file has correct read/write permissions.

weineran avatar Jun 08 '22 23:06 weineran

While workarounds exist (another one would be to check whether the environment variable is set by using something like if [ "$GITHUB_STEP_SUMMARY" != "" ]) I would prefer if this environment variable was provided by act by default.

eserte avatar Jun 22 '22 13:06 eserte

I am getting this error again when I use --env GITHUB_STEP_SUMMARY=/var/run/act/summary:

Error: Unable to access summary file: '/var/run/act/summary'. Check if the file has correct read/write permissions.

Has anyone else seen this and gotten around it? Is there a way to....idk...pass file permissions into act?

weineran avatar Sep 13 '22 04:09 weineran

I am getting this error again when I use --env GITHUB_STEP_SUMMARY=/var/run/act/summary:

Error: Unable to access summary file: '/var/run/act/summary'. Check if the file has correct read/write permissions.

Has anyone else seen this and gotten around it? Is there a way to....idk...pass file permissions into act?

@weineran Have you tried any other path you are able to write to? The path doesn't need to be this exact one, it just has to be a file where you have permission to write to!

mbaeuerle avatar Sep 16 '22 09:09 mbaeuerle

I am getting this error again when I use --env GITHUB_STEP_SUMMARY=/var/run/act/summary:

Error: Unable to access summary file: '/var/run/act/summary'. Check if the file has correct read/write permissions.

Has anyone else seen this and gotten around it? Is there a way to....idk...pass file permissions into act?

You can write to almost anything in /dev thus you can just print back to the terminal (through act) by assigning the GITHUB_STEP_SUMMARY as /dev/stdout

Example: --env GITHUB_STEP_SUMMARY=/dev/stdout

The default for act itself should probably just be this.

tm1000 avatar Sep 22 '22 22:09 tm1000

@weineran Have you tried any other path you are able to write to?

Yes, thanks for the suggestion and apologies for the delayed response. I've been using --env GITHUB_STEP_SUMMARY=/dev/stdout and it works nicely.

You can write to almost anything in /dev thus you can just print back to the terminal (through act) by assigning the GITHUB_STEP_SUMMARY as /dev/stdout The default for act itself should probably just be this

Agreed this should probably be the default. Or possibly /dev/null

Closing this issue again because I am happy with my current workaround.

weineran avatar Sep 26 '22 12:09 weineran

I'd want act to handle both github_step_summary and github_output by providing environment variables that point to files. When a job completes, the former could be dumped to the log. I think I'd probably want the latter to be dumped to the log as well.

jsoref avatar Nov 27 '22 07:11 jsoref

$GITHUB_STEP_SUMMARY was added in #1607

jsoref avatar Apr 04 '24 20:04 jsoref