Skip to content

Commit

Permalink
Add workflow to tag new issues and PRs with community label
Browse files Browse the repository at this point in the history
  • Loading branch information
milank94 committed Dec 4, 2024
1 parent f18e9a2 commit 9f38d90
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/on-community-issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: "Issue Notification"

on:
issues:
types: [opened]
pull_request:
types: [opened]

jobs:
gh-slack-bridge:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- name: Set username and number based on event type
id: set-variables
run: |
if [ "${{ github.event_name }}" = "issues" ]; then
echo "USERNAME=${{ github.event.issue.user.login }}" >> $GITHUB_ENV
echo "NUMBER=${{ github.event.issue.number }}" >> $GITHUB_ENV
echo "EVENT_URL=${{ github.event.issue.html_url }}" >> $GITHUB_ENV
echo "EVENT_TYPE=issue" >> $GITHUB_ENV
echo "GH_COMMAND=issue" >> $GITHUB_ENV
elif [ "${{ github.event_name }}" = "pull_request" ]; then
echo "USERNAME=${{ github.event.pull_request.user.login }}" >> $GITHUB_ENV
echo "NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV
echo "EVENT_URL=${{ github.event.pull_request.html_url }}" >> $GITHUB_ENV
echo "EVENT_TYPE=PR" >> $GITHUB_ENV
echo "GH_COMMAND=pr" >> $GITHUB_ENV
elif [ "${{ github.event_name }}" = "push" ]; then
echo "USERNAME=${{ github.actor }}" >> $GITHUB_ENV
echo "EVENT_URL=https://github.com/${{ github.repository }}/commit/${{ github.sha }}" >> $GITHUB_ENV
echo "EVENT_TYPE=push" >> $GITHUB_ENV
fi
- name: Check if organization member
id: is_organization_member
env:
GITHUB_ORG: tenstorrent
run: |
http_status=$(curl -o /dev/null -s -w '%{http_code}' -H "Authorization: Bearer ${{ secrets.ORG_READ_GITHUB_TOKEN }}" https://api.github.com/orgs/${{ env.GITHUB_ORG }}/members/${{ env.USERNAME }})
if [ "$http_status" -eq 204 ]; then
echo "Detected org member"
echo "is_member=true" >> $GITHUB_OUTPUT
else
echo "Detected community member"
echo "is_member=false" >> $GITHUB_OUTPUT
fi
- name: Add community label
if: ${{ steps.is_organization_member.outputs.is_member == 'false' && env.GH_COMMAND && env.NUMBER }}
run: |
gh ${{env.GH_COMMAND}} edit ${{ env.NUMBER }} --add-label ${{ env.LABELS }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
LABELS: community

0 comments on commit 9f38d90

Please sign in to comment.