Skip to content

Commit 949b44d

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. Closes #8 Signed-off-by: Stefan Zimmermann <user@zimmermann.co>
1 parent 1d9ec21 commit 949b44d

2 files changed

Lines changed: 46 additions & 5 deletions

File tree

.github/workflows/linting.yml

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,65 @@ on:
33
push:
44
pull_request:
55

6+
permissions:
7+
contents: write
8+
pull-requests: write
9+
610
jobs:
711
lint:
12+
name: Lint w/ golangci-lint (auto-fix)
813
runs-on: ubuntu-latest
9-
permissions:
10-
contents: write
11-
1214
steps:
1315
- uses: actions/checkout@v5
1416
with:
1517
fetch-depth: 0
18+
ref: ${{ github.head_ref || github.ref }}
1619

1720
- name: Setup Go environment
1821
uses: actions/setup-go@v6
1922
with:
2023
go-version: 1.25.1
2124

2225
- name: Run go mod tidy
23-
run: go mod tidy
26+
run: |
27+
go mod tidy
2428
2529
- name: Install & run golangci-lint
2630
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8
2731
with:
2832
version: latest
2933
install-mode: "goinstall"
30-
args: --fix
34+
35+
args: --enable godot --fix
36+
37+
- name: Auto-commit lint fixes
38+
id: auto_commit
39+
if: github.event_name == 'pull_request'
40+
uses: stefanzweifel/git-auto-commit-action@778341af668090896ca464160c2def5d1d1a3eb0 # v6.0.1
41+
with:
42+
status_options: --untracked-files=no
43+
44+
commit_message: Auto-fix from ${{ github.workflow }} / ${{ github.job }} job
45+
commit_user_name: github-actions[bot]
46+
commit_user_email: github-actions[bot]@users.noreply.github.com
47+
48+
- name: Comment on PR about the auto-commit
49+
if: github.event_name == 'pull_request' && steps.auto_commit.outputs.changes_detected == 'true'
50+
uses: actions/github-script@v8
51+
with:
52+
script: |
53+
const repositoryUrl = '${{ github.server_url }}/${{ github.repository }}'
54+
55+
await github.rest.issues.createComment({
56+
owner: context.repo.owner,
57+
repo: context.repo.repo,
58+
issue_number: context.issue.number,
59+
body: `
60+
**Auto-fix applied from ${{ github.workflow }}** / \`${{ github.job }}\` job
61+
62+
* Workflow run: ${repositoryUrl}/actions/runs/${{ github.run_id }}
63+
* Fix commit: ${repositoryUrl}/commit/${{ steps.auto_commit.outputs.commit_hash }}
64+
65+
@${{ github.event.pull_request.user.login }}: `
66+
+ 'Please check the auto-changes, pull them, squash commits, & force-push to continue the PR review ...
67+
})

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)