Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,41 @@ jobs:
token: ${{ secrets.GH_TOKEN_FOR_UPDATES }}
```

## With GPG commit signing
## Commit signature
It is possible to sign commits.
There are two ways to do this:
- Automatically, based on the token provided (in this case the commit will be signed as github-actions[bot] when using GITHUB_TOKEN, or your own bot when using GitHub App tokens)
- Manually, by providing a GPG key, passphrase and optionally a fingerprint

### Automatically

To automatically sign commits, set the `sign-commits` input to `true`.
This will use the token provided to sign the commits.
Here's an example of how to using this action with commit signing:

```yaml
name: update-flake-lock

on:
workflow_dispatch: # allows manual triggering
schedule:
- cron: '0 0 * * 1,4' # Run twice a week

jobs:
lockfile:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Determinate Nix
uses: DeterminateSystems/determinate-nix-action@v3
- name: Update flake.lock
uses: DeterminateSystems/update-flake-lock@main
with:
sign-commits: true
```

### With GPG commit signing
Copy link
Member

Choose a reason for hiding this comment

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

Should probably update this example to remove sign-commits so that it's not trying to sign with both the token and GPG?

In fact, we should probably make that an error: specifying both sign-commits as well as gpg-private-key.


It's possible for the bot to produce GPG-signed commits.
Associating a GPG public key to a GitHub user account isn't required but it *is* necessary if you want the signed commits to appear as verified in Github.
Expand Down
16 changes: 9 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ inputs:
GitHub Actions will not run workflows on pull requests which are opened by a GitHub Action.

**To run GitHub Actions workflows on this PR, close and re-open this pull request.**

pr-labels:
description: "A comma or newline separated list of labels to set on the Pull Request to be created"
required: false
Expand Down Expand Up @@ -72,7 +71,9 @@ inputs:
required: false
default: "github-actions[bot]@users.noreply.github.com"
sign-commits:
description: "Set to true if the action should sign the commit with GPG"
description: "Set to true if the action should sign the commit"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
description: "Set to true if the action should sign the commit"
description: "Set to true if the action should sign the commit with the GitHub Actions token"

or something, to make it more explicit that it should only be set in case you want the commit signed by the token and not by GPG, etc

required: false
default: "false"
required: false
default: "false"
gpg-private-key:
Expand Down Expand Up @@ -108,7 +109,7 @@ runs:
using: "composite"
steps:
- name: Import bot's GPG key for signing commits
if: ${{ inputs.sign-commits == 'true' }}
if: ${{ inputs.gpg-private-key != '' }}
id: import-gpg
uses: crazy-max/ghaction-import-gpg@e89d40939c28e39f97cf32126055eeae86ba74ec # v6.3.0
with:
Expand All @@ -118,8 +119,8 @@ runs:
git_config_global: true
git_user_signingkey: true
git_commit_gpgsign: true
- name: Set environment variables (signed commits)
if: ${{ inputs.sign-commits == 'true' }}
- name: Set environment variables (signed commits with GPG)
if: ${{ inputs.gpg-private-key != '' }}
Copy link
Member

Choose a reason for hiding this comment

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

And we don't do this for both cases because create-pull-request handles it for us, I assume?

shell: bash
env:
GIT_AUTHOR_NAME: ${{ steps.import-gpg.outputs.name }}
Expand All @@ -133,7 +134,7 @@ runs:
echo "GIT_COMMITTER_NAME=$GIT_COMMITTER_NAME" >> $GITHUB_ENV
echo "GIT_COMMITTER_EMAIL=<$GIT_COMMITTER_EMAIL>" >> $GITHUB_ENV
- name: Set environment variables (unsigned commits)
if: ${{ inputs.sign-commits != 'true' }}
if: ${{ inputs.gpg-private-key == '' && inputs.sign-commits != 'true' }}
shell: bash
run: |
echo "GIT_AUTHOR_NAME=${{ inputs.git-author-name }}" >> $GITHUB_ENV
Expand Down Expand Up @@ -202,7 +203,7 @@ runs:
run: rm -f pr_body.txt pr_body.template
- name: Create PR
id: create-pr
uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e # v6.0.5
uses: peter-evans/create-pull-request@v7
Copy link
Member

Choose a reason for hiding this comment

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

If you could go back to using the revision associated with the tag at this point in time, that would be swell.

with:
base: ${{ inputs.base }}
branch: ${{ inputs.branch }}
Expand All @@ -215,3 +216,4 @@ runs:
labels: ${{ inputs.pr-labels }}
reviewers: ${{ inputs.pr-reviewers }}
body: ${{ steps.pr_body.outputs.content }}
sign-commits: ${{ inputs.sign-commits }}