|
1 | 1 | name: Rename Go module |
2 | 2 |
|
3 | 3 | 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 ] |
11 | 4 | workflow_dispatch: |
12 | 5 | inputs: |
13 | 6 | source_commit: |
|
19 | 12 | jobs: |
20 | 13 | rename-module: |
21 | 14 | 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' }}" |
26 | 15 | steps: |
27 | 16 | - uses: actions/checkout@v4 |
28 | 17 | with: |
29 | 18 | 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"; |
31 | 29 |
|
32 | 30 | - name: Check out source commit |
33 | | - run: git checkout ${{ env.source_commit }} |
| 31 | + run: git checkout ${{ inputs.source_commit }} |
34 | 32 |
|
35 | 33 | - name: Globally update module name |
36 | 34 | run: | |
@@ -60,22 +58,18 @@ jobs: |
60 | 58 | go build ./...; |
61 | 59 | go test ./accounts/abi/bind ./rlp/rlpgen |
62 | 60 |
|
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}"; |
70 | 67 |
|
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}} |
76 | 72 | 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