Skip to content

Commit 26d4fac

Browse files
committed
feat: signed commit when renaming upstream module
1 parent 21122c0 commit 26d4fac

File tree

1 file changed

+24
-30
lines changed

1 file changed

+24
-30
lines changed
Lines changed: 24 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,23 @@ 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 "DEST_BRANCH=auto-rename-module_source-${{ inputs.source_commit }}_workflow-${WORKFLOW_HASH}-${{ github.ref_name }}" \
28+
>> "$GITHUB_OUTPUT";
3129
3230
- name: Check out source commit
33-
run: git checkout ${{ env.source_commit }}
31+
run: git checkout ${{ inputs.source_commit }}
3432

3533
- name: Globally update module name
3634
run: |
@@ -60,22 +58,18 @@ jobs:
6058
go build ./...;
6159
go test ./accounts/abi/bind ./rlp/rlpgen
6260
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"
61+
- name: Create new branch
62+
env:
63+
BRANCH: ${{ steps.vars.outputs.DEST_BRANCH }}
64+
run: |
65+
git checkout -b "${BRANCH}";
66+
git push origin "${BRANCH}";
7067
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]
68+
- name: Commit to new branch
69+
uses: planetscale/[email protected]
70+
env:
71+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
7672
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_"
73+
commit_message: "[AUTO] rename Go module + update internal import paths"
74+
repo: ${{ github.repository }}
75+
branch: ${{ steps.vars.outputs.DEST_BRANCH }}

0 commit comments

Comments
 (0)