Skip to content

Commit

Permalink
GitHub Action: Auto commit go generate ./... (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
tangrufus authored Dec 6, 2024
1 parent 4ab60d6 commit b37a6e2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 31 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/auto-commit-go.yml
Original file line number Diff line number Diff line change
@@ -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 }}
31 changes: 0 additions & 31 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b37a6e2

Please sign in to comment.