guidelines-check.yml 2.2 KB

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