Skip to content

Commit 219212f

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 219212f

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

.github/workflows/linting.yml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,35 @@ jobs:
2020
go-version: 1.25.1
2121

2222
- name: Run go mod tidy
23-
run: go mod tidy
23+
run: |
24+
go mod tidy
2425
2526
- name: Install & run golangci-lint
2627
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8
2728
with:
2829
version: latest
2930
install-mode: "goinstall"
30-
args: --fix
31+
args: --enable godot --fix
32+
33+
- name: Auto-commit lint fixes
34+
id: auto_commit
35+
if: github.event_name == 'pull_request'
36+
uses: stefanzweifel/git-auto-commit-action@778341af668090896ca464160c2def5d1d1a3eb0 # v6.0.1
37+
with:
38+
commit_message: 'Auto-fix from ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'
39+
40+
- name: Comment on PR about auto-commit
41+
if: steps.auto_commit.outputs.changes_detected == 'true' && github.event_name == 'pull_request'
42+
uses: actions/github-script@v8
43+
with:
44+
script: |
45+
const runUrl = `${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}`
46+
const commitSha = '${{ steps.auto_commit.outputs.commit_hash }}'
47+
const commitUrl = `${{ github.server_url }}/${{ github.repository }}/commit/${commitSha}`
48+
49+
await github.rest.issues.createComment({
50+
issue_number: context.issue.number,
51+
owner: context.repo.owner,
52+
repo: context.repo.repo,
53+
body: `🤖 **Auto-fix applied**\n\nLinting fixes have been automatically committed: [${commitSha.substring(0, 7)}](${commitUrl})\n\n_From workflow run: [${runUrl}](${runUrl})_`
54+
})

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)