Skip to content

Commit cd0ce97

Browse files
ci(GitHub): auto-commit changes from jobs
* Added stefanzweifel/git-auto-commit-action@v6.0.1 to each job. * Further added comment steps explaining the auto-commit.
1 parent 1d9ec21 commit cd0ce97

2 files changed

Lines changed: 41 additions & 5 deletions

File tree

.github/workflows/linting.yml

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ on:
33
push:
44
pull_request:
55

6+
permissions:
7+
contents: write
8+
pull-requests: write
9+
610
jobs:
711
lint:
812
runs-on: ubuntu-latest
9-
permissions:
10-
contents: write
11-
1213
steps:
1314
- uses: actions/checkout@v5
1415
with:
@@ -20,11 +21,42 @@ jobs:
2021
go-version: 1.25.1
2122

2223
- name: Run go mod tidy
23-
run: go mod tidy
24+
run: |
25+
go mod tidy
2426
2527
- name: Install & run golangci-lint
2628
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8
2729
with:
2830
version: latest
2931
install-mode: "goinstall"
30-
args: --fix
32+
33+
args: --enable godot --fix
34+
35+
- name: Auto-commit lint fixes
36+
id: auto_commit
37+
if: github.event_name == 'pull_request'
38+
uses: stefanzweifel/git-auto-commit-action@778341af668090896ca464160c2def5d1d1a3eb0 # v6.0.1
39+
with:
40+
status_options: --untracked-files=no
41+
42+
commit_message: Auto-fix from ${{ github.workflow }} / ${{ github.job }} job
43+
commit_user_name: github-actions[bot]
44+
commit_user_email: noreply@github.com
45+
46+
- name: Comment on PR about the auto-commit
47+
if: github.event_name == 'pull_request' && steps.auto_commit.outputs.changes_detected == 'true'
48+
uses: actions/github-script@v8
49+
with:
50+
script: |
51+
const repositoryUrl = '${{ github.server_url }}/${{ github.repository }}'
52+
53+
github.rest.issues.createComment({
54+
issue_number: context.issue.number,
55+
owner: context.repo.owner,
56+
repo: context.repo.repo,
57+
body: `
58+
**Auto-fix applied from ${{ github.workflow_ref }}** / \`${{ github.job }}\` job
59+
60+
* Workflow run: ${repositoryUrl}/actions/runs/${{ github.run_id }}
61+
* Fix commit: ${repositoryUrl}/commit/${{ steps.auto_commit.outputs.commit_hash }}
62+
`})

pointer.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,7 @@ func NotNilPtr[T any](name string, value *T) *T {
4444
lo.Assertf(value != nil, "%s should not be a nil pointer", name)
4545
return value
4646
}
47+
48+
// bla
49+
func _() {
50+
}

0 commit comments

Comments
 (0)