Skip to content

Add Button and Functionality to Automatically Create a PR adding code.json to Project#40

Merged
IsaacMilarky merged 16 commits intomainfrom
create-pr-from-form
May 2, 2025
Merged

Add Button and Functionality to Automatically Create a PR adding code.json to Project#40
IsaacMilarky merged 16 commits intomainfrom
create-pr-from-form

Conversation

@IsaacMilarky
Copy link
Contributor

Add Button and Functionality to Automatically Create a PR adding code.json to Project

Problem

Currently, the user has to manually add the generated code.json text to the project either with a direct commit or by PR to the desired project.

Solution

Use the GitHub API to add the file via REST requests using Javascript fetch logic.

Result

Summary

  • Add field to input a GitHub API key.
  • Add button to create a PR on the project once the code.json has been generated.
  • Add method to extract owner and repo from the GitHub url given.
  • Add method to create a new branch on the desired project in GitHub.
  • Add method to create a new file (the code.json file) on the new branch created once it is created
  • Add method to create a new PR that merges the new branch into 'main'
  • Add new method createProjectPR that calls all the previous methods using the generated code.json and tells the user if it succeeded or not.
  • Add onclick property to new button that activates createProjectPR to create a functional button

Test Plan

This is tricky to test tbh. I will probably create my own test repo to test all of this to make sure that it is ready for merge.

Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
… file to that branch, and then create a PR into that project

Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
@IsaacMilarky IsaacMilarky marked this pull request as ready for review April 2, 2025 16:30
Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
@IsaacMilarky
Copy link
Contributor Author

Link to example PR created:
IsaacMilarky/TestCodeJSON#2

added debug flag to see what's going on
@sachin-panayil
Copy link
Collaborator

@IsaacMilarky im having trouble getting the feature to work but im not sure if im doing the steps wrong. I have to enter in the code.json information, then generate the code.json, then enter the API key, then click send PR correct?

@IsaacMilarky
Copy link
Contributor Author

@IsaacMilarky im having trouble getting the feature to work but im not sure if im doing the steps wrong. I have to enter in the code.json information, then generate the code.json, then enter the API key, then click send PR correct?

I think you have to put in the API key info before generating the code.json. I can fix that though since it seems kind of confusing.

Copy link
Contributor

@natalialuzuriaga natalialuzuriaga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing amazing job, I was able to get this working on my end 🥳natalialuzuriaga/test-repo#1

A couple of comments addressing error handling and improvements we can make to the user experience of the form. Otherwise, logic makes sense to me and it's working!

Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
Copy link
Contributor

@natalialuzuriaga natalialuzuriaga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did more testing on error handling and found an issue, otherwise this is almost ready to ship!

Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
Copy link
Contributor

@natalialuzuriaga natalialuzuriaga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did testing with different token permissions and error handling works properly. After adding that last alert, this should be good to go and ready to merge!

Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
@IsaacMilarky IsaacMilarky merged commit c4f887d into main May 2, 2025
2 of 4 checks passed
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

Successfully merging this pull request may close these issues.

4 participants