1
0
mirror of https://github.com/fumiama/gozel.git synced 2026-06-05 00:10:24 +08:00

feat: new ci

This commit is contained in:
源文雨
2026-03-26 01:03:34 +08:00
parent 32abd8ea7c
commit 4a1d72447b

View File

@@ -4,7 +4,7 @@ on:
push:
branches: [main]
pull_request:
branches: [main]
types: [opened, synchronize, reopened, labeled]
permissions:
contents: write
@@ -51,11 +51,14 @@ jobs:
version: v2.11
go-generate:
name: Run all Generates & PR
name: Run all Generates & Commit
runs-on: ubuntu-latest
needs: [vet_build_test]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref || github.ref_name }}
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-go@v5
with:
@@ -84,8 +87,31 @@ jobs:
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Commit and push to PR branch
if: steps.diff.outputs.changed == 'true' && github.event_name == 'pull_request'
id: push_to_pr
continue-on-error: true
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "chore: run go generate"
git push
- name: Comment on PR if push failed
if: steps.diff.outputs.changed == 'true' && github.event_name == 'pull_request' && steps.push_to_pr.outcome == 'failure'
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '`go generate` produced file changes but could not be pushed automatically (likely a fork PR). Please run `go generate ./... && gofmt -w .` locally and push the changes.'
})
- name: Create Pull Request
if: steps.diff.outputs.changed == 'true'
if: steps.diff.outputs.changed == 'true' && github.event_name == 'push'
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}