action-semantic-pull-request icon indicating copy to clipboard operation
action-semantic-pull-request copied to clipboard

feat: outputs the error messages

Open juninholiveira opened this issue 3 years ago • 5 comments

Resolves #178

Hello! I'm a new guy here. I took a look at the code and saw that with an easy fix I could "maybe" fix this problem that so many users want: outputs the error messages to other steps/jobs.

You already have @actions/core as a dependency. I just...

  • add a reference to it in validadePrTitle.js
  • create a let that will store the error message
  • instead of just throwing the errors directly by formatting the error message directly in it, I save the message in this variable
  • in the end, I use core.setOutputs to output the error message with the name: "error_message"

I must say: I'm new, not very experienced. I ran the tests and everything passed. But I didn't test in a real workflow. This behaviour is very useful for all users, if you could please take a look in it 🙏

juninholiveira avatar Jul 20 '22 03:07 juninholiveira

This is so cool feature that we actually need now 😃 thanks so much!!!

derberg avatar Jul 20 '22 19:07 derberg

@amannn Worked!!! 🙏

I refactored to a function that first outputs the error message, then throws the error. The problem is that the workflow stops when it receives an error in one of the steps. But this is easily fixed with an "if: always()" in the next step, so it runs the next step (in my case, the action that comments on the PR).

You can see I created a new workflow to test that. I also tested irl on my own repo, with that test I created. And it worked perfectly, the action really commented the error message on my PR (now it's u to the user to decide what action to use for the comment, or whatever it wants to do with the output).

Link to the PR on my repo to prove the working PR: https://github.com/juninholiveira/action-semantic-pull-request/pull/2

If you accept the PR, I can make another PR to add the instructions on the README, if you want.

juninholiveira avatar Jul 20 '22 23:07 juninholiveira

@amannn Hey @amannn, I think everything is ready for deployment. Do you want me to do a final adjustment? (Transform the output variable name from uppercase to snake_case)

juninholiveira avatar Jul 22 '22 18:07 juninholiveira

@amannn Hey, did you decide to drop the feature or closed it because of inactivity from @juninholiveira ?

derberg avatar Aug 16 '22 12:08 derberg

@derberg Strange, I must have closed the PR by accident 🤦‍♂️. I've just reopened it.

There was one comment remaining, other than that the PR would be fine.

amannn avatar Aug 22 '22 14:08 amannn

:tada: This PR is included in version 4.6.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

github-actions[bot] avatar Sep 26 '22 08:09 github-actions[bot]