Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Add a workflow for a notification on new discussions (#121)

Madison Swain-Bowdenb15fa61b8339
diff --git a/.github/GITHUB.md b/.github/GITHUB.md
index bf54904cd..f17586b8e 100644
--- a/.github/GITHUB.md
+++ b/.github/GITHUB.md
@@ -80,3 +80,11 @@ channel. This ping is not sent for PRs made by Dependabot and downstream sync
action.
**PR:** opened
+
+### New discussion notification
+
+This workflow makes a `POST` request to the Slack webhook when a new
+discussion is created, sending a notification message to the
+`#openverse-notifications` channel.
+
+**Discussion:** created
diff --git a/.github/workflows/discussion_ping.yml b/.github/workflows/discussion_ping.yml
new file mode 100644
index 000000000..b2434a7d5
--- /dev/null
+++ b/.github/workflows/discussion_ping.yml
@@ -0,0 +1,27 @@
+name: New discussion notification
+# ℹ️ https://github.com/WordPress/openverse/blob/main/.github/GITHUB.md#new-discussion-notification
+
+on:
+ discussion:
+ types:
+ - created
+
+jobs:
+ send_message:
+ name: Send Slack message
+ runs-on: ubuntu-latest
+ env:
+ slack_url: ${{ secrets.SLACK_WEBHOOK_URL }}
+ discussion_url: ${{ github.event.discussion.html_url }}
+ discussion_number: ${{ github.event.discussion.number }}
+ discussion_title: ${{ github.event.discussion.title }}
+ discussion_author: ${{ github.event.discussion.user.login }}
+ discussion_repo: ${{ github.event.repository.full_name }}
+ steps:
+ - name: Send notification for new discussion
+ run: |
+ curl \
+ $slack_url \
+ -X POST \
+ -H 'Content-Type: application/json' \
+ -d '{"text":"New discussion opened by '"$discussion_author"' in '"$discussion_repo"': #'"$discussion_number"' - '"$discussion_title"'","blocks":[{"type":"section","text":{"type":"mrkdwn","text":":github: New discussion opened by *'"$discussion_author"'* in `'"$discussion_repo"'`:\n<'"$discussion_url"'|#'"$discussion_number"' - '"$discussion_title"'>"}}]}'