From a17bdd2809619304ba4ee932cf48074094c2c607 Mon Sep 17 00:00:00 2001 From: Artem Yerofieiev Date: Fri, 28 Jun 2024 21:21:18 +0000 Subject: [PATCH 1/8] #0: Added github community issue workflow --- .github/workflows/on-community-issue.yaml | 37 +++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/on-community-issue.yaml diff --git a/.github/workflows/on-community-issue.yaml b/.github/workflows/on-community-issue.yaml new file mode 100644 index 00000000000..09ce2809308 --- /dev/null +++ b/.github/workflows/on-community-issue.yaml @@ -0,0 +1,37 @@ +name: "Slack Notification on Community Issue" + +on: + push: + issues: + types: [opened, labeled] + +jobs: + label-check: + runs-on: ubuntu-latest + + steps: + - name: Check issue labels + id: label-check + uses: actions/github-script@v7 + with: + script: | + const issue = context.payload.issue; + if (!issue || issue.pull_request) { + console.log("This event is not an issue or is a pull request."); + return false; + } + const labels = context.payload.issue.labels.map(label => label.name); + const requiredLabel = "community"; + const hasRequiredLabel = labels.includes(requiredLabel); + return hasRequiredLabel; + - name: Send Slack Notification + if: steps.label-check.outputs.result == 'true' + uses: slackapi/slack-github-action@v1.26.0 + with: + payload: | + { + "text": "A new issue with the 'community' label has been created by `${{ github.event.sender.login }}`: ${{ github.event.issue.html_url }}", + "channel": "" + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CHANNEL_WEBHOOK_URL }} From ccf91e123d9e4026bffb327e0245769d0f31e158 Mon Sep 17 00:00:00 2001 From: Artem Yerofieiev <169092593+ayerofieiev-tt@users.noreply.github.com> Date: Fri, 28 Jun 2024 14:23:47 -0700 Subject: [PATCH 2/8] #0: Update channel id --- .github/workflows/on-community-issue.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on-community-issue.yaml b/.github/workflows/on-community-issue.yaml index 09ce2809308..6ea9a8d1ee1 100644 --- a/.github/workflows/on-community-issue.yaml +++ b/.github/workflows/on-community-issue.yaml @@ -31,7 +31,7 @@ jobs: payload: | { "text": "A new issue with the 'community' label has been created by `${{ github.event.sender.login }}`: ${{ github.event.issue.html_url }}", - "channel": "" + "channel": "C07AZJ5DLL8" } env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CHANNEL_WEBHOOK_URL }} From 77049dfa07da7123d6ef23f53cfd348e16f63c59 Mon Sep 17 00:00:00 2001 From: Artem Yerofieiev <169092593+ayerofieiev-tt@users.noreply.github.com> Date: Fri, 28 Jun 2024 14:27:08 -0700 Subject: [PATCH 3/8] #0: Check that webhook works --- .github/workflows/on-community-issue.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on-community-issue.yaml b/.github/workflows/on-community-issue.yaml index 6ea9a8d1ee1..7f5883605aa 100644 --- a/.github/workflows/on-community-issue.yaml +++ b/.github/workflows/on-community-issue.yaml @@ -25,7 +25,7 @@ jobs: const hasRequiredLabel = labels.includes(requiredLabel); return hasRequiredLabel; - name: Send Slack Notification - if: steps.label-check.outputs.result == 'true' + if: steps.label-check.outputs.result == 'false' uses: slackapi/slack-github-action@v1.26.0 with: payload: | From 74b05c156f9710ef8d971d30abce52ea31d90dad Mon Sep 17 00:00:00 2001 From: Artem Yerofieiev <169092593+ayerofieiev-tt@users.noreply.github.com> Date: Fri, 28 Jun 2024 14:32:02 -0700 Subject: [PATCH 4/8] #0: Try to log some more --- .github/workflows/on-community-issue.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/on-community-issue.yaml b/.github/workflows/on-community-issue.yaml index 7f5883605aa..50b7eaa8c74 100644 --- a/.github/workflows/on-community-issue.yaml +++ b/.github/workflows/on-community-issue.yaml @@ -1,7 +1,6 @@ name: "Slack Notification on Community Issue" -on: - push: +on: issues: types: [opened, labeled] @@ -15,6 +14,7 @@ jobs: uses: actions/github-script@v7 with: script: | + console.log(context.payload) const issue = context.payload.issue; if (!issue || issue.pull_request) { console.log("This event is not an issue or is a pull request."); @@ -25,7 +25,7 @@ jobs: const hasRequiredLabel = labels.includes(requiredLabel); return hasRequiredLabel; - name: Send Slack Notification - if: steps.label-check.outputs.result == 'false' + if: steps.label-check.outputs.result == 'true' uses: slackapi/slack-github-action@v1.26.0 with: payload: | From 0a31b6d257ac57addb5cebdfd5471ac9a8bc3bb1 Mon Sep 17 00:00:00 2001 From: Artem Yerofieiev Date: Fri, 28 Jun 2024 21:35:52 +0000 Subject: [PATCH 5/8] #0: Change the check --- .github/workflows/on-community-issue.yaml | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/.github/workflows/on-community-issue.yaml b/.github/workflows/on-community-issue.yaml index 50b7eaa8c74..f3e778e1560 100644 --- a/.github/workflows/on-community-issue.yaml +++ b/.github/workflows/on-community-issue.yaml @@ -1,6 +1,6 @@ name: "Slack Notification on Community Issue" -on: +on: issues: types: [opened, labeled] @@ -9,23 +9,8 @@ jobs: runs-on: ubuntu-latest steps: - - name: Check issue labels - id: label-check - uses: actions/github-script@v7 - with: - script: | - console.log(context.payload) - const issue = context.payload.issue; - if (!issue || issue.pull_request) { - console.log("This event is not an issue or is a pull request."); - return false; - } - const labels = context.payload.issue.labels.map(label => label.name); - const requiredLabel = "community"; - const hasRequiredLabel = labels.includes(requiredLabel); - return hasRequiredLabel; - name: Send Slack Notification - if: steps.label-check.outputs.result == 'true' + if: contains(github.event.issue.labels.*.name, 'community') uses: slackapi/slack-github-action@v1.26.0 with: payload: | From 4454734564307e3bedac866a1d22e026943c7706 Mon Sep 17 00:00:00 2001 From: Artem Yerofieiev <169092593+ayerofieiev-tt@users.noreply.github.com> Date: Fri, 28 Jun 2024 14:48:21 -0700 Subject: [PATCH 6/8] #0: switched check to an org member --- .github/workflows/on-community-issue.yaml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/on-community-issue.yaml b/.github/workflows/on-community-issue.yaml index f3e778e1560..bff8eebbed0 100644 --- a/.github/workflows/on-community-issue.yaml +++ b/.github/workflows/on-community-issue.yaml @@ -9,13 +9,20 @@ jobs: runs-on: ubuntu-latest steps: - - name: Send Slack Notification - if: contains(github.event.issue.labels.*.name, 'community') + - name: Check if organization member + id: is_organization_member + if: github.event.action == 'opened' + uses: JamesSingleton/is-organization-member@1.0.0 + with: + organization: tenstorrent + username: ${{ github.event.issue.user.login }} + token: ${{ secrets.GITHUB_TOKEN }} + - name: Send Slack Notification uses: slackapi/slack-github-action@v1.26.0 with: payload: | { - "text": "A new issue with the 'community' label has been created by `${{ github.event.sender.login }}`: ${{ github.event.issue.html_url }}", + "text": "A new issue has been created by a non-org member `${{ github.event.sender.login }}`: ${{ github.event.issue.html_url }}", "channel": "C07AZJ5DLL8" } env: From d3210533dd1fe46bed8385aad06d9c00080bf2d8 Mon Sep 17 00:00:00 2001 From: Artem Yerofieiev <169092593+ayerofieiev-tt@users.noreply.github.com> Date: Fri, 28 Jun 2024 14:53:44 -0700 Subject: [PATCH 7/8] #0: Add label: community to non-org issues --- .github/workflows/on-community-issue.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/on-community-issue.yaml b/.github/workflows/on-community-issue.yaml index bff8eebbed0..e15977c11c6 100644 --- a/.github/workflows/on-community-issue.yaml +++ b/.github/workflows/on-community-issue.yaml @@ -17,6 +17,12 @@ jobs: organization: tenstorrent username: ${{ github.event.issue.user.login }} token: ${{ secrets.GITHUB_TOKEN }} + - run: gh issue edit "$NUMBER" --add-label "$LABELS" + env: + GH_TOKEN: ${€ secrets.GITHUB_TOKEN 3} + GH_REPO: ${ github. repository }} + NUMBER: ${{ github.event.issue.number }} + LABELS: community - name: Send Slack Notification uses: slackapi/slack-github-action@v1.26.0 with: From a9f3f89ae3075295741c6d4474cc5656f6ab0548 Mon Sep 17 00:00:00 2001 From: Artem Yerofieiev <169092593+ayerofieiev-tt@users.noreply.github.com> Date: Fri, 28 Jun 2024 15:13:56 -0700 Subject: [PATCH 8/8] #0: Switch to org check + labels addition --- .github/workflows/on-community-issue.yaml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/on-community-issue.yaml b/.github/workflows/on-community-issue.yaml index e15977c11c6..63af9e0c159 100644 --- a/.github/workflows/on-community-issue.yaml +++ b/.github/workflows/on-community-issue.yaml @@ -11,20 +11,22 @@ jobs: steps: - name: Check if organization member id: is_organization_member - if: github.event.action == 'opened' uses: JamesSingleton/is-organization-member@1.0.0 with: organization: tenstorrent username: ${{ github.event.issue.user.login }} token: ${{ secrets.GITHUB_TOKEN }} - - run: gh issue edit "$NUMBER" --add-label "$LABELS" + - name: Add community label + if: ${{ steps.is_organization_member.outputs.result == 'false' }} + run: gh issue edit "$NUMBER" --add-label "$LABELS" env: - GH_TOKEN: ${€ secrets.GITHUB_TOKEN 3} - GH_REPO: ${ github. repository }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} NUMBER: ${{ github.event.issue.number }} LABELS: community - - name: Send Slack Notification - uses: slackapi/slack-github-action@v1.26.0 + - name: Send Slack Notification + if: ${{ steps.is_organization_member.outputs.result == 'false' }} + uses: slackapi/slack-github-action@v1.26.0 with: payload: | {