4

I want to automatically create a Github issue with an action if a job fails. In this issue, I want to include the log in the issue body but I can't figure out how to get this log.

I've tried using the Github CLI gh run view --log-failed --job <jobID>. However, this requires the job ID, which is tough to impossible to get for a matrix job. I've tried this action, but my matrix uses a stringified JSON matrix value which creates a truncated job name so this doesn't solve the problem reliably. Also, when trying this command locally, I receive an empty response with the --log or --log-failed flags.

I am currently creating the issue in the same job as the failing one using if: ${{ failure() }}.

Any tips or ideas for how I can auto-create an issue containing job failure logs in the body? Too many yaks are getting shaved.

tvandinther
  • 371
  • 3
  • 13
  • 1
    Maybe explicitly write the log to a file with `tee` and upload it as an asset before failing? – tla Mar 04 '23 at 15:26
  • Thanks. I resorted to swapping out the `uses` steps with `run` and using tee. Not the most elegant solution, but I've really reached the limitations of Github Actions trying to do this. – tvandinther Mar 08 '23 at 02:10

0 Answers0