Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for GitHub API commit #2046

Merged
merged 4 commits into from
Apr 25, 2024

Conversation

MattiasAng
Copy link
Contributor

@MattiasAng MattiasAng commented Apr 24, 2024

Fix #1914

This pull request adds support for GitHub API commit. It allows Github SCM to commit a file in a GitHub repository using the GitHub API instead of using native Git.

The GitHub commit API is useful when a user is using the automated token from Github Actions as it creates a signed commit automatically, removing the requirement of using a bot account with a GPG key configured.

For now I've hidden this feature behind the commitUsingApi (not loving the parameter name, happy for suggestions).

In addition I changed the Github pull request action to check if working branch is ahead using the API instead of relying on the native Git handler as I kept running in to issues where Github Actions wasn't recognizing changes done (not exactly sure why, but I think this will 100% ensure that the commit is available in Github).

As can be seen in the below screenshot, the commit is shown as verified with the Github Actions bot user committing the changes.
image

Test

Build my fork and use the Github SCM with commitUsingApi: true.

@MattiasAng
Copy link
Contributor Author

@olblak Leaving this in draft for now as I am still doing some testing in our organization, but happy to get any feedback. I'll see if I can get some tests in as well when I get some more time.

@MattiasAng MattiasAng force-pushed the gh-api-commit branch 2 times, most recently from a34eb57 to 0686bc6 Compare April 24, 2024 11:44
@olblak
Copy link
Member

olblak commented Apr 24, 2024

Spelling issues can be ignored by adding them to https://github.com/updatecli/updatecli/blob/main/.github/actions/spelling/allow.txt

@olblak olblak added enhancement New feature or request scm-github SCM of type GiHhub labels Apr 24, 2024
@MattiasAng MattiasAng marked this pull request as ready for review April 24, 2024 15:51
This commit adds support for GitHub API commit.
It allows to update a file in a GitHub repository
using the GitHub API instead of using git.

The GitHub API commit is useful when a user
is using the automated token from Github Actions
as it creates a signed commit automatically.
@MattiasAng MattiasAng force-pushed the gh-api-commit branch 2 times, most recently from 4b05bdd to 008d116 Compare April 24, 2024 15:56
@MattiasAng
Copy link
Contributor Author

MattiasAng commented Apr 24, 2024

Added a pattern to remove spellcheck on lines where it didn't make sense which was a bit easier than having to add exclusions for base64 strings. 😄

Copy link
Member

@olblak olblak left a comment

Choose a reason for hiding this comment

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

Thanks for the pullrequest, it looks great.
I didn't test it yet, but I am planning to release a new release candidate 0.76.0-rc.2 so we can see how it behaves during a few days

@olblak olblak added this to the 0.76.0 milestone Apr 25, 2024
@olblak olblak merged commit bec3fcc into updatecli:main Apr 25, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request scm-github SCM of type GiHhub
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Automated signed commits for GitHub Actions if a github-bot
2 participants