From b37a6e2c56e4efec276a85219e52360146d765fe Mon Sep 17 00:00:00 2001 From: Tang Rufus Date: Fri, 6 Dec 2024 00:04:38 +0000 Subject: [PATCH] GitHub Action: Auto commit `go generate ./...` (#19) --- .github/workflows/auto-commit-go.yml | 29 ++++++++++++++++++++++++++ .github/workflows/go.yml | 31 ---------------------------- 2 files changed, 29 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/auto-commit-go.yml diff --git a/.github/workflows/auto-commit-go.yml b/.github/workflows/auto-commit-go.yml new file mode 100644 index 0000000..6f532c0 --- /dev/null +++ b/.github/workflows/auto-commit-go.yml @@ -0,0 +1,29 @@ +name: Auto Commit (Go) + +on: + workflow_dispatch: + push: + branches: + - main + +concurrency: + group: ${{ github.workflow }}-${{ github.ref_name }} + cancel-in-progress: true + +permissions: {} + +jobs: + go-generate: + uses: typisttech/.github/.github/workflows/create-auto-merged-pull-request-go.yml@v1 + permissions: + contents: write + pull-requests: write + with: + command: go generate ./... + branch: "bot/go-generate/${{ github.ref_name }}" + labels: | + bot + go-generate + secrets: + pr-write-pat-token: ${{ secrets.PR_WRITE_PAT_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index ba91221..059ab0d 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -57,34 +57,3 @@ jobs: - uses: codecov/codecov-action@v5 with: use_oidc: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork) }} - - generate-diff: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version-file: 'go.mod' - - run: go mod tidy -diff - - run: go mod download - - run: go mod verify - - run: go generate ./... - - name: Detect uncommitted changes - run: | - changes=$(git status --porcelain) - if [[ -n "$changes" ]]; then - { - echo '## :construction: Uncommitted changes' - echo 'Run `$ go generate ./...` to re-generate the files.' - echo '```console' - echo '$ git status --porcelain' - echo "$changes" - echo '```' - } >> "$GITHUB_STEP_SUMMARY" - - echo "::group::Uncommitted changes" - echo "$changes" - echo "::endgroup::" - - exit 1 - fi