lgtm.yml 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
  21. with:
  22. sparse-checkout: |
  23. CODEOWNERS.md
  24. .github/scripts
  25. persist-credentials: false
  26. # Generate a GitHub App installation access token
  27. - name: Generate token
  28. id: generate_token
  29. uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
  30. env:
  31. LGTM_APP_ID: ${{ secrets.LGTM_APP_ID }}
  32. LGTM_PRIVATE_KEY: ${{ secrets.LGTM_PRIVATE_KEY }}
  33. with:
  34. app-id: ${{ env.LGTM_APP_ID }}
  35. private-key: ${{ env.LGTM_PRIVATE_KEY }}
  36. owner: ${{ github.repository_owner }}
  37. - name: Slash Command Dispatch
  38. uses: peter-evans/slash-command-dispatch@9bdcd7914ec1b75590b790b844aa3b8eee7c683a # v5.0.2
  39. with:
  40. token: ${{ steps.generate_token.outputs.token }}
  41. reaction-token: ${{ secrets.GITHUB_TOKEN }}
  42. issue-type: pull-request
  43. commands: lgtm
  44. permission: none # anyone can use the command, but permissions are checked in the workflow itself.
  45. - name: Process LGTM Command
  46. if: ${{ github.event.comment.body == '/lgtm' }}
  47. uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v7
  48. with:
  49. github-token: ${{ steps.generate_token.outputs.token }}
  50. script: |
  51. const { default: run } = await import(`${process.env.GITHUB_WORKSPACE}/.github/scripts/lgtm-processor.js`);
  52. await run({ core, github, context, fs: require('fs') });