lgtm.yml 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # If someone with reviewer access comments "/lgtm" on a pull request, add lgtm label
  2. name: LGTM Command
  3. on:
  4. issue_comment:
  5. types: [created]
  6. permissions:
  7. contents: read
  8. jobs:
  9. lgtm-command:
  10. permissions:
  11. pull-requests: write # for peter-evans/slash-command-dispatch to create PR reaction
  12. issues: write # for adding labels and comments
  13. contents: read # for reading CODEOWNERS.md
  14. runs-on: ubuntu-latest
  15. # Only run for PRs, not issue comments
  16. if: ${{ github.event.issue.pull_request }}
  17. steps:
  18. # Checkout repo to access CODEOWNERS.md
  19. - name: Checkout repository
  20. uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v5
  21. with:
  22. sparse-checkout: |
  23. CODEOWNERS.md
  24. # Generate a GitHub App installation access token
  25. - name: Generate token
  26. id: generate_token
  27. uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0
  28. with:
  29. app-id: ${{ secrets.LGTM_APP_ID }}
  30. private-key: ${{ secrets.LGTM_PRIVATE_KEY }}
  31. owner: ${{ github.repository_owner }}
  32. - name: Slash Command Dispatch
  33. uses: peter-evans/slash-command-dispatch@9bdcd7914ec1b75590b790b844aa3b8eee7c683a # v5.0.2
  34. with:
  35. token: ${{ steps.generate_token.outputs.token }}
  36. reaction-token: ${{ secrets.GITHUB_TOKEN }}
  37. issue-type: pull-request
  38. commands: lgtm
  39. permission: none # anyone can use the command, but permissions are checked in the workflow itself.
  40. - name: Process LGTM Command
  41. if: ${{ github.event.comment.body == '/lgtm' }}
  42. uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v7
  43. with:
  44. github-token: ${{ steps.generate_token.outputs.token }}
  45. script: |
  46. const { default: run } = await import(`${process.env.GITHUB_WORKSPACE}/.github/scripts/lgtm-processor.js`);
  47. await run({ core, github, context, fs: require('fs') });