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

ci: signed commits #95

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

sparten11740
Copy link
Contributor

@sparten11740 sparten11740 commented Apr 25, 2024

Our branch protection rules require us to use signed commits. This adds changes the committer to the bot that creates the PR and enables GPG signing

Testplan

Tested in https://github.com/ExodusMovement/lerna-version-selectively/pull/504

mvayngrib
mvayngrib previously approved these changes Apr 25, 2024
@@ -37,11 +38,21 @@ jobs:
run: yarn install --immutable
- name: Prepare
run: yarn prepare
- name: Import GPG key
id: import-gpg
uses: crazy-max/ghaction-import-gpg@1a317071222a9bfb1839df1b58b1f0dcd893b589
Copy link
Collaborator

Choose a reason for hiding this comment

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

@633kh4ck could u have a look at this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I gave this a review and I can't see any malicious attempts at trying to steal the keys. Note that I didn't review the openpgp package which has access to the private key here: https://github.com/crazy-max/ghaction-import-gpg/blob/60f6f3e9a98263cc2c51ebe1f9babe82ded3f0ba/src/openpgp.ts#L18-L20

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good to merge for now? the consequence of that GPG key leaking wouldn't be dramatic imo

Copy link
Collaborator

Choose a reason for hiding this comment

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

ping @633kh4ck

Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need a thirdparty action for this / why can't this be a command?

@mvayngrib
Copy link
Collaborator

ping @633kh4ck

@sparten11740
Copy link
Contributor Author

sparten11740 commented Jul 8, 2024

we can stop using the 3rd party action and go for a vanilla approach instead such as

      - name: Configure GPG Key
        run: | 
          echo -n "${{ secrets. GPG_PRIVATE_KEY }}" | base64 --decode | gpg --import
          git config --global user.signingkey ABCD1234

@633kh4ck
Copy link
Contributor

633kh4ck commented Jul 8, 2024

we can stop using the 3rd party action and go for a vanilla approach instead such as

It looks safer and cleaner at first glance (or we need to audit third-party code, including openpgp package). However, we would also need to implement passphrase support (see https://github.com/hashicorp/ghaction-import-gpg/blob/2c0efc4138244c5ffcc48520962918bf8a166eee/action.yml and https://gist.github.com/vansergen/88eb7e71fea2e3bdaf6aa3e752371eb7 for a general idea) and cleanup stage (https://github.com/crazy-max/ghaction-import-gpg/blob/1a317071222a9bfb1839df1b58b1f0dcd893b589/src/main.ts#L134-L148).

Copy link

Houston, this is Conflict Bot. We have a conflict. I repeat, we have a conflict. @sparten11740 please rebase. Acknowledge.

@ChALkeR
Copy link
Contributor

ChALkeR commented Aug 16, 2024

Another way would be to use GH API to generate commits instead, which is what other gh actions do

image

Then we won't have to sign them manually at all

@ChALkeR
Copy link
Contributor

ChALkeR commented Aug 16, 2024

Single-file updates: https://docs.github.com/en/rest/repos/contents#create-or-update-file-contents (you also want branch and sha options)
This should work nicely

Fine-grained API which can build a commit with changes across multiple files: https://docs.github.com/en/rest/git/commits#create-a-commit
Not entirely sure if this one works to make the same kind of API verified commits

@mvayngrib
Copy link
Collaborator

@marcoskichel we currently use git here but looks like we can use the GH API to get signed commits. Could you have a look when you have time?

@sparten11740
Copy link
Contributor Author

Changing the files through the API has two disadvantages:

it's subject to API rate limits (not a big deal if we only do it in this repo) and which is more annoying: we need to be explicit as to what files need updating. In this case all package.json's and changelogs of the released packages and potentially the lockfile. I find the git cli with signed commits more appealing tbh

@mvayngrib
Copy link
Collaborator

@sparten11740 does this PR need to be updated to use https://github.com/ExodusMovement/git-signing-action ?

@sparten11740
Copy link
Contributor Author

Yes, but we first have to make the action repo public. Any objections?

@mvayngrib
Copy link
Collaborator

just asked on Slack in #ossing-requests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants