label-comments.yml 1.9 KB

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