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

Cannot sign commit using Github App auth #1241

Closed
andridzi opened this issue Aug 30, 2022 · 9 comments
Closed

Cannot sign commit using Github App auth #1241

andridzi opened this issue Aug 30, 2022 · 9 comments

Comments

@andridzi
Copy link

andridzi commented Aug 30, 2022

Subject of the issue

Cannot sign commit using Github App auth.

Steps to reproduce

As mentioned in docs, Signature verification for bots will only work if there is no custom author information, custom committer information, and no custom signature information.

Even if put correct committer and author fields commit will not be signed.
It will be signed only when committer and author fields not set at all.

@peter-evans
Copy link
Owner

Hi @andridzi

Please could you explain in more detail about what you are trying and what does/doesn't work.

It will be signed only when committer and author fields not set at all.

So are you saying it works when you set the committer and author to empty strings? e.g.

      - uses: peter-evans/create-pull-request@v4
        with:
          committer: ''
          author: ''

@andridzi
Copy link
Author

Hi @peter-evans,

Yes, something like that. And inside the action when committer and author are empty strings, they should not be passed to the API call.

From what I've found during the investigation.

Commit will be signed:

curl \
      -X PUT \
      -H "Authorization: token GITHUB_APP_TOKEN" \
      -H "Accept: application/vnd.github.v3+json" \
      https://api.github.com/repos/someOrg/someRepo/contents/test1 \
      -d '{"message":"message","content":"Y29udGVudA==","branch":"master"}'

Commit will NOT be signed:

curl \
      -X PUT \
      -H "Authorization: token GITHUB_APP_TOKEN" \
      -H "Accept: application/vnd.github.v3+json" \
      https://api.github.com/repos/someOrg/someRepo/contents/test2 \
      -d '{"committer":{"name":"GitHub","email":"noreply@github.com"},"author":{"name":"your-github-app[bot]","email":"112472085+your-github-app[bot]@users.noreply.github.com"},"message":"message","content":"Y29udGVudA==","branch":"master"}'

And when comparing both commits through the GitHub API - the only difference (except date, hash etc.) is that first one is signed, and second one isn't.

@peter-evans
Copy link
Owner

@andridzi I'm not sure how to approach this problem because this action does not use the API you mentioned. Commits are made locally in the GitHub Actions run using the Git protocol, not the REST API.

If I was to allow author and committer to be empty strings then Git would complain and wouldn't allow commits to take place. I think at least one of those must exists for commits to be successful using the git command line.

@andridzi
Copy link
Author

andridzi commented Sep 1, 2022

@peter-evans Yes, indeed. I missed that commits created using Git protocol.

So, currently in peter-evans/create-pull-request action it's not possible to create Verified commits using Github App auth token. And I think it will be good to mention this somewhere in the docs.

@peter-evans
Copy link
Owner

Signature verification for bots will only work if the request is verified and authenticated as the GitHub App or bot and contains no custom author information, custom committer information, and no custom signature information, such as Commits API.

Is it not possible to achieve this without using GitHub's REST API for committing? Perhaps there is some way to do this using the git protocol, too.

@lemeurherve
Copy link

Git is the way:
https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification

If a commit or tag has a GPG, SSH, or S/MIME signature that is cryptographically verifiable, GitHub marks the commit or tag "Verified" or "Partially verified."

@peter-evans
Copy link
Owner

I've documented how you can do it with GPG here:
https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#gpg-commit-signature-verification

Not sure if something like this can work with tokens generated from a GitHub auth app, though.

@peter-evans
Copy link
Owner

Closing this for now because it appears to not be possible.

@HenryNguyen5
Copy link

HenryNguyen5 commented Feb 23, 2023

Yeah, its not possible to create signed commits with a github app token without using github's REST or GQL API https://github.com/orgs/community/discussions/24664#discussioncomment-5084236

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

No branches or pull requests

4 participants