Auto go generate for pull request #1
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Go Generate and Commit | |
on: | |
pull_request: | |
branches: | |
- main | |
types: | |
- opened | |
- synchronize | |
jobs: | |
build: | |
if: "!contains(github.event.head_commit.message, 'Generate files')" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
fetch-depth: 0 | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.20.x' | |
- name: Run go generate | |
run: | | |
go generate ./... | |
- name: Commit and push if changed | |
run: | | |
git config --global user.name 'GitHub Action' | |
git config --global user.email 'action@github.com' | |
git diff --quiet || (git add -A && git commit -m "Generate files" && git push) |