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

Add support for signed commits #3055

Merged

Conversation

rustycl0ck
Copy link
Contributor

Add support for automatically signing the commits as github-actions bot. This is useful in cases where repo/org owners have enforced a signed-commit policy. If a custom github-token is provided for another Github App, then the commit will be signed as that app.

This PR is related to or addresses the following issues:

I am a newbie with Typescript, so I have not separated out the logic to a different file or broken it into smaller functions/utilities. I might be able to spend a little bit more time on it to implement suggestions, but if it requires major refactoring, then please feel free to refactor and push the commits directly (or can also merge this PR and then refactor separately in a new PR).

@rustycl0ck rustycl0ck marked this pull request as ready for review July 24, 2024 09:01
@peter-evans
Copy link
Owner

Thank you for contributing this feature! Your timing is impeccable. I was just talking with a colleague today about needing this feature!

If I understand correctly, this only works for app-generated tokens, correct? I wonder what happens if you try to sign with a PAT. I guess the default GITHUB_TOKEN counts as an app token of the github-actions bot. Anyway, I'll test it and confirm.

@peter-evans peter-evans changed the base branch from main to signed-commits July 25, 2024 13:11
@peter-evans
Copy link
Owner

I tried to make changes directly to your branch, but I don't have permission it seems. I'll merge to a feature branch before merging to main.

@peter-evans peter-evans merged commit dfa3f7a into peter-evans:signed-commits Jul 25, 2024
@rustycl0ck
Copy link
Contributor Author

Thank you for picking up this PR so quickly and for improving. Looking forward to seeing this feature in a new release soon!

@peter-evans
Copy link
Owner

There's quite a bit of work to do before I can release this, but your contribution is a great start. Thank you!

Working on it here:

@rustycl0ck
Copy link
Contributor Author

Ah I see... Yes, that looks like a lot of work really! Just passing all the test cases itself would have been quite challenging for me. Thank you very much for continuing to maintain this very useful Github Action and for continuing to add features.

peter-evans pushed a commit that referenced this pull request Jul 31, 2024
peter-evans pushed a commit that referenced this pull request Aug 6, 2024
peter-evans pushed a commit that referenced this pull request Aug 14, 2024
peter-evans pushed a commit that referenced this pull request Aug 20, 2024
peter-evans pushed a commit that referenced this pull request Aug 27, 2024
peter-evans added a commit that referenced this pull request Sep 3, 2024
* Add support for signed commits (#3055)

* formatting

* fix eslint and lint errors

* shift setting the base to before the push

* sign commits by default for testing

* add debug lines

* read to buffer not string and use non-legacy method to base64

* debug payload without contents

* disable linter for debug code

* fix filepath when using path input

* try to fix head repo

* remove commented code

* Try refactor of file changes

* add tests for building file changes

* add build file changes test for binary files

* refactor graphql code into github helper class

* build file changes even when there is no diff

* add function to get commit detail

* fix format

* build branch commits

* use source mode for deleted files

* try rest api route

* fix check for branch existence

* force push

* try fix base tree

* debug commit verification

* debug commit verification

* fix format and cleanup

* add executable mode file to test

* limit blob creation concurrency

* only build commits when feature enabled

* remove unused code

* update readme link

* update docs for commit signing

* fix capital letter

* update docs

* add throttling

* set default back to false

* output head sha and verified status

* log outputs

* fix head sha output

* default the operation output to none

* output retryafter for secondary rate limit

* use separate client for branch and pull operations

* add maintainer-can-modify input

* rename git-token to branch-token

* fix branch token input

* remove deprecated env output

* update docs

* fix doc

* update docs

* build branch commits when there is a diff with the base

* check verification status of head commit when not known

* fix verified output when no commit signing is being used

* draft always-true

* convert to draft on branch updates when there is a diff with base

* update docs with blob size limit

* catch errors during blob creation for debugging

* parse empty commits

* pass base commit to push signed commits

* use parent commit details in create commit

* use parent tree for base_tree

* multipart tree creation

* update docs

* update readme about the permissions of the default token

* fix edge case where changes are partially merged

* add updating documentation

* fix typo

* update major version

---------

Co-authored-by: Ravi <1299606+rustycl0ck@users.noreply.github.com>
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.

2 participants