From 1c8d223fd7ffb5a25eb4bdd69e16f1f788daeef8 Mon Sep 17 00:00:00 2001 From: Robel Getnet Geremew Date: Tue, 21 Jan 2025 18:51:23 +0300 Subject: [PATCH] Authoring Fix CI (#1275) * initial commit * added git username and email * use ssh instead * added ssh key * add private key as text * reverted ssh changes * use third party actions to setup ssh * push in a separate step * log old author commit * use original email instead of obscured one for GitHub * moved push back into first step * use input for referencing emails and usernames removed testing triggers * removed push trigger * changed repo url for testing on main * reverted url changes made for testing --- .github/workflows/reauthor.yaml | 59 +++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/reauthor.yaml diff --git a/.github/workflows/reauthor.yaml b/.github/workflows/reauthor.yaml new file mode 100644 index 000000000..c92a08b83 --- /dev/null +++ b/.github/workflows/reauthor.yaml @@ -0,0 +1,59 @@ +name: Re-author +on: + workflow_dispatch: + inputs: + previous_email: + required: true + description: 'Author to change (email)' + type: string + new_email: + required: true + description: 'New author email' + type: string + new_username: + required: true + description: 'New author username' + type: string + +jobs: + reauthor: + name: Re-author job + runs-on: ubuntu-latest + steps: + - name: Set-up SSH + uses: MrSquaare/ssh-setup-action@v1 + with: + host: github.com + private-key: ${{ secrets.DEPLOY_KEY }} + - name: Clone and Re-author + run: | + git clone --bare git@github.com:ChainSafe/web3.unity.git + + cd web3.unity.git + + git config user.email "$new_email" + + git config user.name $new_username + + #!/bin/sh + + git filter-branch -f --env-filter ' + OLD_EMAIL="$previous_email" + CORRECT_NAME="$new_username" + CORRECT_EMAIL="$new_email" + if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ] + then + export GIT_COMMITTER_NAME="$CORRECT_NAME" + export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL" + fi + if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ] + then + export GIT_AUTHOR_NAME="$CORRECT_NAME" + export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL" + fi + ' --tag-name-filter cat -- --branches --tags + git push --force --tags origin 'refs/heads/*' + env: + previous_email: ${{ github.event.inputs.previous_email }} + new_email: ${{ github.event.inputs.new_email }} + new_username: ${{ github.event.inputs.new_username }} \ No newline at end of file