lgtm.yml 2.1 KB

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