lgtm-remove-on-update.yml 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. name: Pull Request Maintenance
  2. on:
  3. pull_request_target:
  4. types: [synchronize]
  5. permissions:
  6. contents: read
  7. jobs:
  8. remove-lgtm:
  9. permissions:
  10. pull-requests: write # for removing labels
  11. issues: write # for removing labels and adding comments
  12. runs-on: ubuntu-latest
  13. steps:
  14. - name: Remove LGTM label on PR update
  15. uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v7
  16. with:
  17. script: |
  18. const prNumber = context.payload.pull_request.number;
  19. const owner = context.repo.owner;
  20. const repo = context.repo.repo;
  21. const labelName = 'lgtm';
  22. // Check if LGTM label exists
  23. const labels = await github.rest.issues.listLabelsOnIssue({
  24. owner, repo, issue_number: prNumber
  25. });
  26. const hasLGTM = labels.data.some(l => l.name === labelName);
  27. if (!hasLGTM) {
  28. console.log('No LGTM label found, nothing to remove');
  29. return;
  30. }
  31. // Remove LGTM label
  32. try {
  33. await github.rest.issues.removeLabel({
  34. owner, repo, issue_number: prNumber, name: labelName
  35. });
  36. console.log('LGTM label removed');
  37. } catch (error) {
  38. console.log('Failed to remove LGTM label:', error.message);
  39. return;
  40. }