unroute-new-issue.yml 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. name: Unroute new issue
  2. on:
  3. issues:
  4. types: ["opened"]
  5. jobs:
  6. unroute-new-issue:
  7. runs-on: ubuntu-latest
  8. steps:
  9. - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
  10. - name: "Unroute new issue"
  11. shell: bash
  12. env:
  13. GITHUB_TOKEN: ${{ github.token }}
  14. run: |
  15. issue_number=${{ github.event.issue.number }}
  16. echo "Unrouting issue #${issue_number}."
  17. # Trust users who belong to the getsentry org.
  18. if gh api "https://api.github.com/orgs/getsentry/members/${{ github.actor }}" >/dev/null 2>&1; then
  19. echo "Skipping unrouting, because ${{ github.actor }} is a member of the getsentry org."
  20. exit 0
  21. else
  22. echo "${{ github.actor }} is not a (public?) member of the getsentry org. 🧐"
  23. fi
  24. # Helper
  25. function gh-issue-label() {
  26. gh api "/repos/:owner/:repo/issues/${1}/labels" \
  27. -X POST \
  28. --input <(echo "{\"labels\":[\"$2\"]}")
  29. }
  30. gh-issue-label "${issue_number}" "Status: Unrouted"