issue-routing-helper.yml 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. name: Issue Routing Helper
  2. on:
  3. issues:
  4. types: [labeled]
  5. env:
  6. # Use GH_RELEASE_PAT as github-actions bot is not allowed to ping teams
  7. GH_TOKEN: ${{ secrets.GH_RELEASE_PAT }}
  8. GH_REPO: ${{ github.repository }}
  9. jobs:
  10. route:
  11. runs-on: ubuntu-latest
  12. if: "startsWith(github.event.label.name, 'Team: ')"
  13. steps:
  14. - name: "Ensure a single 'Team: *' label with 'Status: Untriaged'"
  15. run: |
  16. labels_to_remove=$(gh api --paginate "/repos/$GH_REPO/labels" -q '[.[].name | select((startswith("Team: ") or startswith("Status: ")) and . != "${{ github.event.label.name }}" and . != "Status: Untriaged")] | join(",")')
  17. gh issue edit ${{ github.event.issue.number }} --remove-label "$labels_to_remove" --add-label '${{ github.event.label.name }},Status: Untriaged'
  18. - name: "Mention/ping assigned team for triage"
  19. run: |
  20. # Get team label mention name:
  21. team_label='${{ github.event.label.name }}'
  22. team_name="${team_label:6}" # Strip the first 6 chars, which is the 'Team: ' part
  23. team_slug="${team_name// /-}" # Replace spaces with hyphens for url/slug friendliness
  24. mention_slug=$(gh api "/orgs/getsentry/teams/$team_slug" -q .slug || true)
  25. if [[ -z "$mention_slug" ]]; then
  26. echo "Couldn't find team mention from slug, trying the label description"
  27. team_slug=$(gh api "/repos/$GH_REPO/labels/$team_label" -q '.description')
  28. mention_slug=$(gh api "/orgs/getsentry/teams/$team_slug" -q .slug || true)
  29. fi
  30. if [[ -n "$mention_slug" ]]; then
  31. echo "Routing to @getsentry/$mention_slug for [triage](https://develop.sentry.dev/processing-tickets/#3-triage). ⏲️" > comment_body
  32. else
  33. echo "[Failed]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID) to route to \`${{ github.event.label.name }}\`. 😕" > comment_body
  34. echo "" >> comment_body
  35. echo "Defaulting to @getsentry/open-source for [triage](https://develop.sentry.dev/processing-tickets/#3-triage). ⏲️" >> comment_body
  36. fi
  37. gh issue comment ${{ github.event.issue.number }} --body-file comment_body