|
3 | 3 | push: |
4 | 4 | pull_request: |
5 | 5 |
|
| 6 | +permissions: |
| 7 | + contents: write |
| 8 | + pull-requests: write |
| 9 | + |
6 | 10 | jobs: |
7 | 11 | lint: |
| 12 | + name: Lint w/ golangci-lint |
8 | 13 | runs-on: ubuntu-latest |
9 | | - permissions: |
10 | | - contents: write |
11 | | - |
12 | 14 | steps: |
13 | 15 | - uses: actions/checkout@v5 |
14 | 16 | with: |
15 | 17 | fetch-depth: 0 |
| 18 | + ref: ${{ github.head_ref || github.ref }} |
16 | 19 |
|
17 | 20 | - name: Setup Go environment |
18 | 21 | uses: actions/setup-go@v6 |
19 | 22 | with: |
20 | 23 | go-version: 1.25.1 |
21 | 24 |
|
22 | 25 | - name: Run go mod tidy |
23 | | - run: go mod tidy |
| 26 | + run: | |
| 27 | + go mod tidy |
24 | 28 |
|
25 | 29 | - name: Install & run golangci-lint |
26 | 30 | uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8 |
27 | 31 | with: |
28 | 32 | version: latest |
29 | 33 | 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 | + `}) |
0 commit comments