Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What steps are needed to commit and push to GitHub from CodeBuild?

I’m trying to have yarn publish an NPM package in CodeBuild, and then push the updated package.json back to GitHub Enterprise. Everything is working except the push part. It’s not a credentials issue because the CodeBuild is able to fetch everything from the GitHub server (SSH has already been setup).

Once it has the pushed tag, it is:

  1. Setting user.name and user.email for git config
  2. Finding the branch that the tag was pushed to: git branch —-contains tags/<tag> | sed -n 2p | awk ‘{printf $1}’
  3. Checking out that branch: git checkout <branch>
  4. Publishing via yarn publish —-no-git-tag-version —-new-version <version from tag> which also changes and commits the package.json change.
  5. Finally it runs git push origin <branch>

Step 1-4 seem to be working great, but step 5 just outputs “everything up-to-date” even though yarn publish changed and committed the package.json.

What else needs to be done to commit/push from CodeBuild? I’ve also tried putting git fetch —-unshallow before everything in case it needed more info, but that didn’t change anything. It’s as if checking out a branch in CodeBuild doesn’t track the remote branch?

like image 299
ParkerD Avatar asked Aug 26 '26 12:08

ParkerD


1 Answers

After step 4, it seems you haven't committed anything to your current branch. Check git status for untracked and modified files, you can add these using git add <files> or add all using git add ..

Once this is done, you can use git status again to check that the files have been added correctly, and commit the files with git commit and you should be able to push successfully.

like image 66
Green-Avocado Avatar answered Aug 28 '26 03:08

Green-Avocado



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!