Skip to content

Commit c287e20

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 c287e20

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

.github/workflows/linting.yml

Lines changed: 25 additions & 1 deletion
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"
3031
args: --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+
})

0 commit comments

Comments
 (0)