Skip to content

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

Ping for new PRs on Slack (#98)

Dhruv Bhanushali61166e9a2412
diff --git a/.github/GITHUB.md b/.github/GITHUB.md
index ea6e9c9f1..8d7f81740 100644
--- a/.github/GITHUB.md
+++ b/.github/GITHUB.md
@@ -63,4 +63,11 @@ outlining the closed issues and merged PRs of the preceding week. The post can
be reviewed manually and then published.
**Cron:** [at 00:01 on Monday](https://crontab.guru/#1_0_*_*_1)
-**Dispatch:** enabled
\ No newline at end of file
+**Dispatch:** enabled
+
+### New PR notification
+
+This workflow makes a `POST` request to the Slack webhook when a new PR is
+created, sending a notification message to the `#openverse` channel.
+
+**PR:** opened
diff --git a/.github/sync.yml b/.github/sync.yml
index c8cec7740..4c3454aa0 100644
--- a/.github/sync.yml
+++ b/.github/sync.yml
@@ -12,6 +12,8 @@ group:
dest: .github/workflows/new_prs.yml
- source: .github/workflows/pr_label_check.yml
dest: .github/workflows/pr_label_check.yml
+ - source: .github/workflows/pr_ping.yml
+ dest: .github/workflows/pr_ping.yml
- source: .github/ISSUE_TEMPLATE/
dest: .github/ISSUE_TEMPLATE/
- source: .github/PULL_REQUEST_TEMPLATE.md
diff --git a/.github/workflows/pr_ping.yml b/.github/workflows/pr_ping.yml
new file mode 100644
index 000000000..d809a7a8a
--- /dev/null
+++ b/.github/workflows/pr_ping.yml
@@ -0,0 +1,27 @@
+name: New PR notification
+# ℹ️ https://github.com/WordPress/openverse/blob/main/.github/GITHUB.md#new-pr-notification
+
+on:
+ pull_request_target:
+ types:
+ - opened
+
+jobs:
+ send_message:
+ name: Send message
+ if: ${{ !github.event.pull_request.draft }}
+ runs-on: ubuntu-latest
+ steps:
+ - name: Send Slack notification
+ run: |
+ curl \
+ $slack_url \
+ -X POST \
+ -H 'Content-Type: application/json' \
+ -d '{"blocks": [{"type":"section","text":{"type":"mrkdwn","text":":pull-request: New PR by *'"$pr_author"'* in `'"$pr_repo"'`:\n<'"$pr_url"'|'"$pr_title"'>"}}]}'
+ env:
+ slack_url: ${{ secrets.SLACK_WEBHOOK_URL }}
+ pr_url: ${{ github.event.pull_request.html_url }}
+ pr_title: ${{ github.event.pull_request.title }}
+ pr_author: ${{ github.event.pull_request.user.login }}
+ pr_repo: ${{ github.event.pull_request.repo.full_name }}