Creating commits only if changes present #1938
-
I have a bit of an interesting use case for using the library that does the following:
The script is run from a developers local machine (the CI process to do it through Jenkins has yet to be set up, so it is what it is for the time being, unfortunately). However, I'm seeing a few issues:
I'm basically trying to convert commands I wrote in node that use a shell to do all of this with the bot. If it's helpful, here are the steps in code which I'm trying to commit: Step 1 from above:
Step 2 from above:
Step 3 from above:
So far I've really only been able to figure out how to do an actual commit with the bot through the SDK, but am stumped on the rest, unfortunately. Any help would be greatly appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 12 replies
-
hey there, I think you'll have more luck asking on https://github.community/ or on Stack Overflow. This discussion forum is for the JavaScript Octokit libraries, none of which you seem to be using here? |
Beta Was this translation helpful? Give feedback.
-
@gr2m Not a problem, I appreciate you looking at it and responding. |
Beta Was this translation helpful? Give feedback.
-
In your code you don't interact with the local git repository at all, you only interact with the remote repository. I think I'm still missing something, but I don't understand how you expect the local changes to be cleaned up by the API calls? |
Beta Was this translation helpful? Give feedback.
-
@gr2m Yes, totally understand that I need to implement one or the other. I'm refactoring the And yes, I am implementing a release automation tool that is built around auto. What we're actually talking about is a custom auto config that I'm working on. The problem is, because I have to jump through hoops to add the private registry (Artifactory) authentication token to the npmrc file, and then subsequently remove it (because the token is only necessary for publishing and it's passed down through environment variables that we don't want to commit into the Git repo), I'm running into these issues with dirty filesystem commits for the dev running the script locally. I hope that makes sense and helps clarify the situation i'm facing. |
Beta Was this translation helpful? Give feedback.
-
YES! the last paragraph of what you said is exactly it! I want to ensure a clean filesystem on the user's machine before they push (this is more-so a safety precaution, publish guidelines tell them to ensure this before publishing, but I have trust issues), and yes, they cannot push to master because of auth (I was unaware of this limitation when I originally set this up as I had admin rights and everything worked fine for me until someone that didn't tried to run the script). I can certainly create a PR and merge the branch using the API if that is the only solution available. What would that code look like? I guess I'd need two PRs in my scenario, one for the ensuring of clean filesystem, then another for the This seems alot more complex than it should be but if this is the only/best way to circumvent all this, I'm certainly willing to do that. It seems like I'd be creating 3 extra commits on every publish. |
Beta Was this translation helpful? Give feedback.
-
I should also mention that there is a github action on PRs that checks for certain labels being applied (as that is whats needed for |
Beta Was this translation helpful? Give feedback.
-
to summerize in my own words, you want to do the following when someone runs
Do I have that right? I wonder if it wouldn't make more sense to not attempt to push the local changes, but instead reject to run the publish with a helpful message, asking the user to push the local changes themselves and then run publish again? |
Beta Was this translation helpful? Give feedback.
-
Yes, that is correct! I'm totally ok that, for step 1, we exit the process and message the user to commit their local changes. That's completely a viable thing to do, I'm just not sure how to do that with the SDK. As for step 2, that's exactly right. Here is the order of steps that the script runs:
|
Beta Was this translation helpful? Give feedback.
-
@gr2m I've simplified the approach I was taking after speaking with you yesterday because you helped me realize a few things:
Other than the status check in #1, the only other question remaining then is this: After I run |
Beta Was this translation helpful? Give feedback.
@gr2m I've simplified the approach I was taking after speaking with you yesterday because you helped me realize a few things:
.tmp-npmrc
and.npmrc
files. Just creating those, publishing, and then removing is sufficient without git interaction.--no-git-tag-version
to thenpm version [version]
command as I realizedauto
does the tagging for you alre…