guidelines-check.yml 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. name: Guidelines Check
  2. on:
  3. # Disabled - uncomment to re-enable
  4. # pull_request_target:
  5. # types: [opened, synchronize]
  6. jobs:
  7. check-guidelines:
  8. runs-on: ubuntu-latest
  9. permissions:
  10. contents: read
  11. pull-requests: write
  12. steps:
  13. - name: Checkout repository
  14. uses: actions/checkout@v4
  15. with:
  16. fetch-depth: 1
  17. - name: Install opencode
  18. run: curl -fsSL https://opencode.ai/install | bash
  19. - name: Check PR guidelines compliance
  20. env:
  21. ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
  22. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  23. OPENCODE_PERMISSION: '{ "bash": { "gh*": "allow", "gh pr review*": "deny", "*": "deny" } }'
  24. run: |
  25. opencode run -m anthropic/claude-sonnet-4-20250514 "A new pull request has been created: '${{ github.event.pull_request.title }}'
  26. <pr-number>
  27. ${{ github.event.pull_request.number }}
  28. </pr-number>
  29. <pr-description>
  30. ${{ github.event.pull_request.body }}
  31. </pr-description>
  32. 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
  33. Use the gh cli to create comments on the files for the violations. Try to leave the comment on the exact line number. If you have a suggested fix include it in a suggestion code block.
  34. Command MUST be like this.
  35. ```
  36. gh api \
  37. --method POST \
  38. -H "Accept: application/vnd.github+json" \
  39. -H "X-GitHub-Api-Version: 2022-11-28" \
  40. /repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/comments \
  41. -f 'body=[summary of issue]' -f 'commit_id=${{ github.event.pull_request.head.sha }}' -f 'path=[path-to-file]' -F "line=[line]" -f 'side=RIGHT'
  42. ```
  43. Only create comments for actual violations. If the code follows all guidelines, don't run any gh commands."