Skip to content

Commit c6c8558

Browse files
authored
feat: signed commit when renaming upstream module (#61)
## Why this should be merged Signs commits for auto-renaming the Go module, originally introduced in #51 with unsigned commits that can't be merged to `main`. ## How this works Changes the commit action to use [`ghcommit`](https://github.com/planetscale/ghcommit), which was made specifically to allow for keyless signing (GitHub signs the commit). The workflow no longer opens a PR to the `renamed-go-module` branch as it's redundant and the generated branch can be used directly. The commit message includes the `workflow_dispatch` trigger branch as well as a hash of the workflow file for a complete audit trail. I removed the commented-out PR trigger as it's unnecessary. In development we can now just trigger the workflow on the dev branch. ## How this was tested Inspecting [the commit](ava-labs@572b8ab) generated by a [workflow run](https://github.com/ava-labs/libevm/actions/runs/11357025696/job/31589219847). It is identical in modifications to the one reviewed in #59.
1 parent 21122c0 commit c6c8558

File tree

1 file changed

+25
-30
lines changed

1 file changed

+25
-30
lines changed
Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
name: Rename Go module
22

33
on:
4-
# During development, the next two lines MAY be enabled to have the PR
5-
# automatically run this workflow for inspection of the resulting branch.
6-
# However, they MUST be disabled again before merging otherwise *all* PRs will
7-
# run this.
8-
#
9-
# pull_request:
10-
# branches: [ main ]
114
workflow_dispatch:
125
inputs:
136
source_commit:
@@ -19,18 +12,24 @@ on:
1912
jobs:
2013
rename-module:
2114
runs-on: ubuntu-latest
22-
env:
23-
source_commit: "${{ inputs.source_commit || '2bd6bd01d2e8561dd7fc21b631f4a34ac16627a1' }}"
24-
# env variables cannot reference others so we have to duplicate the ||
25-
output_branch: "${{ github.ref_name }}_auto-rename-module-${{ inputs.source_commit || '2bd6bd01d2e8561dd7fc21b631f4a34ac16627a1' }}"
2615
steps:
2716
- uses: actions/checkout@v4
2817
with:
2918
fetch-depth: 0 # everything
30-
fetch-tags: true
19+
20+
- name: Set variables
21+
id: vars
22+
# Including hashes of both the source commit and the workflow file makes
23+
# this idempotent.
24+
env:
25+
WORKFLOW_HASH: ${{ hashFiles('.github/workflows/rename-module.yml') }}
26+
run: |
27+
echo "WORKFLOW_HASH=${WORKFLOW_HASH}" >> "$GITHUB_OUTPUT";
28+
echo "DEST_BRANCH=auto-rename-module_source-${{ inputs.source_commit }}_workflow-${WORKFLOW_HASH}-${{ github.ref_name }}" \
29+
>> "$GITHUB_OUTPUT";
3130
3231
- name: Check out source commit
33-
run: git checkout ${{ env.source_commit }}
32+
run: git checkout ${{ inputs.source_commit }}
3433

3534
- name: Globally update module name
3635
run: |
@@ -60,22 +59,18 @@ jobs:
6059
go build ./...;
6160
go test ./accounts/abi/bind ./rlp/rlpgen
6261
63-
- name: Commit to new branch
64-
uses: devops-infra/action-commit-push@8bc2ff9f9de7aa2a7581fc7e5b6401c04cab54c7
65-
with:
66-
github_token: ${{ secrets.GITHUB_TOKEN }}
67-
target_branch: ${{ env.output_branch }}
68-
force: true
69-
commit_prefix: "[AUTO] rename Go module + update internal import paths"
62+
- name: Create new branch
63+
env:
64+
BRANCH: ${{ steps.vars.outputs.DEST_BRANCH }}
65+
run: |
66+
git checkout -b "${BRANCH}";
67+
git push origin "${BRANCH}";
7068
71-
- name: Open PR to "renamed-go-module" iff workflow dispatched on "main"
72-
# If we are changing the way in which we manage module renaming then it
73-
# MUST go through PR review to main; only then can it open PRs.
74-
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'
75-
uses: devops-infra/[email protected]
69+
- name: Commit to new branch
70+
uses: planetscale/ghcommit-action@d4176bfacef926cc2db351eab20398dfc2f593b5 # v0.2.0
71+
env:
72+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
7673
with:
77-
github_token: ${{ secrets.GITHUB_TOKEN }}
78-
source_branch: ${{ env.output_branch }}
79-
target_branch: renamed-go-module
80-
title: "[AUTO] Rename upstream Go module at `${{ env.source_commit }}`"
81-
body: "_PR generated by GitHub Action_"
74+
commit_message: "[AUTO] rename Go module + update internal import paths\n\nWorkflow: ${{ steps.vars.outputs.WORKFLOW_HASH }} on branch ${{ github.ref_name }}"
75+
repo: ${{ github.repository }}
76+
branch: ${{ steps.vars.outputs.DEST_BRANCH }}

0 commit comments

Comments
 (0)