2
0

label-comments.yml 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. name: needs-follow-up-label
  2. on:
  3. issue_comment:
  4. types: [created]
  5. issues:
  6. types: [opened, reopened, closed]
  7. jobs:
  8. set-follow-up-label:
  9. runs-on: ubuntu-latest
  10. steps:
  11. - name: Check comment actor org membership
  12. id: response
  13. run: |
  14. echo "::set-output name=MEMBER_RESPONSE::$(curl -I -H 'Accept: application/vnd.github+json' -H 'Authorization: token ${{ github.token }}' 'https://api.github.com/orgs/kubecost/members/${{ github.actor }}')"
  15. - name: "Check for non-4XX response"
  16. id: membership
  17. run: |
  18. echo '${{ steps.response.outputs.MEMBER_RESPONSE }}' && echo "::set-output name=IS_MEMBER::$(grep 'HTTP/2 [2]' <<< '${{ steps.response.outputs.MEMBER_RESPONSE }}')"
  19. - name: Apply needs-follow-up label if this is a new or reopened issue by user not in the org
  20. if: ${{ steps.membership.outputs.IS_MEMBER == '' && github.event_name == 'issues' && (github.event.action == 'opened' || github.event.action == 'reopened') }}
  21. uses: actions-ecosystem/action-add-labels@v1
  22. with:
  23. labels: needs-follow-up
  24. - name: Apply needs-follow-up label if comment by a user not in the org
  25. if: ${{ steps.membership.outputs.IS_MEMBER == '' && github.event_name == 'issue_comment' }}
  26. uses: actions-ecosystem/action-add-labels@v1
  27. with:
  28. labels: needs-follow-up
  29. - name: Remove needs-follow-up label if the issue has been closed
  30. if: ${{ github.event_name == 'issues' && github.event.action == 'closed' }}
  31. uses: actions-ecosystem/action-remove-labels@v1
  32. with:
  33. labels: needs-follow-up
  34. - name: Remove needs-follow-up label if comment by a user in the org
  35. if: ${{ steps.membership.outputs.IS_MEMBER != '' && github.event_name == 'issue_comment' }}
  36. uses: actions-ecosystem/action-remove-labels@v1
  37. with:
  38. labels: needs-follow-up