Skip to content

Commit 62198cb

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 62198cb

2 files changed

Lines changed: 57 additions & 5 deletions

File tree

.github/workflows/linting.yml

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,76 @@ 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
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: Set PR to draft
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+
await github.rest.pulls.update({
54+
owner: context.repo.owner,
55+
repo: context.repo.repo,
56+
pull_number: context.issue.number,
57+
draft: true
58+
})
59+
60+
- name: Comment on PR about the auto-commit
61+
if: github.event_name == 'pull_request' && steps.auto_commit.outputs.changes_detected == 'true'
62+
uses: actions/github-script@v8
63+
with:
64+
script: |
65+
const repositoryUrl = '${{ github.server_url }}/${{ github.repository }}'
66+
67+
await github.rest.issues.createComment({
68+
issue_number: context.issue.number,
69+
owner: context.repo.owner,
70+
repo: context.repo.repo,
71+
body: `
72+
**Auto-fix applied from ${{ github.workflow }}** / \`${{ github.job }}\` job
73+
74+
* Workflow run: ${repositoryUrl}/actions/runs/${{ github.run_id }}
75+
* Fix commit: ${repositoryUrl}/commit/${{ steps.auto_commit.outputs.commit_hash }}
76+
77+
@${{ github.event.pull_request.user.login }}: Please pull, squash commits, & force push to continue the PR review ...
78+
`})

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)