@@ -619,15 +619,20 @@ jobs:
619619 SONAR_SCANNER_OPTS : " -Xms6g -Xmx8g"
620620
621621 clean :
622- name : Clean Go Tidy & Generate
622+ name : Go Tidy & Generate
623623 if : ${{ github.actor != 'dependabot[bot]' }}
624624 runs-on : ubuntu22.04-8cores-32GB
625+ permissions :
626+ contents : write
627+ env :
628+ GH_TOKEN : ${{ github.token }}
625629 defaults :
626630 run :
627631 shell : bash
628632 steps :
629633 - uses : actions/checkout@v6
630634 with :
635+ ref : ${{ github.head_ref }}
631636 persist-credentials : false
632637 - name : Setup Go
633638 uses : ./.github/actions/setup-go
@@ -638,24 +643,28 @@ jobs:
638643 https://github.com/smartcontractkit/wsrpc/raw/main/cmd/protoc-gen-go-wsrpc/protoc-gen-go-wsrpc
639644 --output "$HOME/go/bin/protoc-gen-go-wsrpc" && chmod +x
640645 " $HOME/go/bin/protoc-gen-go-wsrpc"
641- - name : make generate
646+ - name : tidy & generate
642647 run : |
648+ make gomodtidy
643649 make rm-mocked
644650 make generate
645- - name : Ensure clean after generate
651+ - name : Commit if not clean
652+ if : github.event_name == 'pull_request'
646653 run : |
647654 git add --all
648655 if ! git diff --cached --quiet; then
649- echo "::error::Tree is dirty after 'make generate'. Full diff below:"
650- git diff --cached
651- exit 1
656+ echo "Tree is dirty. Pushing commit"
657+ git config user.name "github-actions[bot]"
658+ git config user.email "github-actions[bot]@users.noreply.github.com"
659+ git commit -m "chore: tidy & generate"
660+ git push
652661 fi
653- - run : make gomodtidy
654- - name : Ensure clean after tidy
662+ - name : Ensure clean
663+ if : github.event_name != 'pull_request'
655664 run : |
656665 git add --all
657666 if ! git diff --cached --quiet; then
658- echo "::error::Tree is dirty after 'make gomodtidy' . Full diff below:"
667+ echo "::error::Tree is dirty after tidy & generate . Full diff below:"
659668 git diff --cached
660669 exit 1
661670 fi
0 commit comments