actions icon indicating copy to clipboard operation
actions copied to clipboard

feat: Add optional project_name to action

Open miguel-botelho opened this issue 2 years ago • 1 comments

This PR adds a new optional property called project_name, so that the comments created by the Github action are unique, based on current stack_infra + project_name. This will facilitate working with Pulumi actions inside monorepos, so that multiple jobs are ran in a PR and each job will have its own comment, given they are for different stacks or projects. Besides that, also added a bit more tests around the pr spec.

On another note, I went with creating project_name as optional, not sure on what is the desired approach for this one. Also, if there's any way to find the name of the Pulumi project without the user specifying on the YML, I believe would be less intrusive (but I couldn't find by reading the project's source code a way to do so). Feedback is more than welcomed!

Fixes #563

miguel-botelho avatar Oct 15 '22 09:10 miguel-botelho

Oh, I also wanted to say thanks for fixing up the tests too!

RobbieMcKinstry avatar Oct 15 '22 18:10 RobbieMcKinstry

Hey, @miguel-botelho thank you very much for your contribution and especially for implementing this so quickly!

if there's any way to find the name of the Pulumi project without the user specifying on the YML, I believe would be less intrusive

IMO, I think we can get the project name programmatically using the Automation API. The Project Settings have a field for the project name.

For example, we import items from the Automation API here.

You should be able to get an instance of ProjectSettings using this method. I think this method is callable whenever, but you might want to wait until after this line so the stack is selected. Forgive me, I'm not very well-versed on the Automation API.

Hey @RobbieMcKinstry , many thanks for the help and the quick review. I ended up passing the projectName as a property of the current Config object, not sure if there's a better/cleaner approach, so feel free to leave your feedback on this one: https://github.com/pulumi/actions/pull/755/commits/905033c83c161c244e8f241489f19de036111ee3

miguel-botelho avatar Oct 17 '22 10:10 miguel-botelho

Another question, how can I test this development on one of my projects?

miguel-botelho avatar Oct 17 '22 11:10 miguel-botelho

Another question, how can I test this development on one of my projects?

I think you can refer to the public URL and commit SHA (or branch name).

https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-versioned-actions

RobbieMcKinstry avatar Oct 18 '22 17:10 RobbieMcKinstry

Hey @cobraz @RobbieMcKinstry 👋 Many thanks for the review and help getting this one figured out. I've made the necessary changes to retrieve the projectName automatically and pass it down to the handlePullRequest method. I also went ahead and compiled the project in this branch (I've already reverted it) to test it on one of our monorepos, and it looks like it's working:

image

Feel free to review it again and leave your feedback on this one 😄

miguel-botelho avatar Oct 19 '22 09:10 miguel-botelho

Hey @RobbieMcKinstry , sorry for pinging you again, were you able to review this one? 🙏

miguel-botelho avatar Oct 28 '22 14:10 miguel-botelho

Hey @RobbieMcKinstry , just rebased it with the most recent changes in master, it's good to take a look again 👍

miguel-botelho avatar Nov 09 '22 11:11 miguel-botelho

@miguel-botelho Would you be willing to send me an email at [email protected]? I want to send a small thank-you gift from Pulumi for your contribution.

RobbieMcKinstry avatar Nov 10 '22 17:11 RobbieMcKinstry

@miguel-botelho Would you be willing to send me an email at [email protected]? I want to send a small thank-you gift from Pulumi for your contribution.

Many thanks! I'll ping you there in a few minutes. Also, I'm the one that should be thanking for guiding me during the review phase 🙇

miguel-botelho avatar Nov 10 '22 17:11 miguel-botelho

Hah, anytime, friend!

RobbieMcKinstry avatar Nov 10 '22 18:11 RobbieMcKinstry