summaryrefslogtreecommitdiffhomepage
path: root/.github/workflows/guidelines-check.yml
blob: 7cec751fe3b6942765dd8522af1774b85463f51e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: Guidelines Check

on:
  pull_request_target:
    types: [opened, synchronize]

jobs:
  check-guidelines:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 1

      - name: Install opencode
        run: curl -fsSL https://opencode.ai/install | bash

      - name: Check PR guidelines compliance
        env:
          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          OPENCODE_PERMISSION: '{ "bash": { "gh*": "allow", "*": "deny" } }'
        run: |
          opencode run -m anthropic/claude-sonnet-4-20250514 "A new pull request has been created: '${{ github.event.pull_request.title }}'

          <pr-number>
          ${{ github.event.pull_request.number }}
          </pr-number>

          <pr-description>
          ${{ github.event.pull_request.body }}
          </pr-description>

          Please check all the code changes in this pull request against the guidelines in AGENTS.md file in this repository. Diffs are important but make sure you read the entire file to get proper context. Make it clear the suggestions are merely suggestions and the human can decide what to do

          For each violation you find, create a file comment using the following command EXACTLY as shown:

          ```
          gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/comments -f body='[description of problem]' -f path='[path-to-file]' -f line=[line-number] -f side='RIGHT'
          ```

          If you have a suggestion for how to fix the problem the body can include a suggestion:
          ```
          \`\`\`suggestion
          [suggested code here]
          \`\`\`
          ```

          Only create comments for actual violations. If the code follows all guidelines, don't run any gh commands."