Skip to content

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

Replaced `cURL` slack workflows with `slackapi` (#3577)

Pk Patelfa632e63240e
diff --git a/.github/workflows/discussion_ping.yml b/.github/workflows/discussion_ping.yml
index 243eedec7..7a4ef5af9 100644
--- a/.github/workflows/discussion_ping.yml
+++ b/.github/workflows/discussion_ping.yml
@@ -11,17 +11,28 @@ jobs:
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 }}
+ SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
+ SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
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"'>"}}]}'
+ id: slack
+ uses: slackapi/[email protected]
+ with:
+ payload: |
+ {
+ "text": "New discussion opened by ${{ env.discussion_author }} in ${{ env.discussion_repo }}: #${{ env.discussion_number }} - ${{ env.discussion_title }}",
+ "blocks": [
+ {
+ "type": "section",
+ "text": {
+ "type": "mrkdwn",
+ "text": ":github: New discussion opened by *${{ env.discussion_author }}* in ${{ env.discussion_repo }}:\n<${{ env.discussion_url }}|#${{ env.discussion_number }} - ${{ env.discussion_title }}>"
+ }
+ }
+ ]
+ }
diff --git a/.github/workflows/pr_limit_reminders.yml b/.github/workflows/pr_limit_reminders.yml
index fbb408448..6e67dfacf 100644
--- a/.github/workflows/pr_limit_reminders.yml
+++ b/.github/workflows/pr_limit_reminders.yml
@@ -29,19 +29,17 @@ jobs:
if: ${{ needs.analyze-user-prs.outputs.pr_count >= 3 }}
runs-on: ubuntu-latest
env:
- slack_url: ${{ secrets.SLACK_DM_WEBHOOK_URL }}
pr_count: ${{ needs.analyze-user-prs.outputs.pr_count }}
slack_id: ${{ needs.analyze-user-prs.outputs.slack_id }}
+ SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
+ SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
steps:
- name: Send notification
- run: |
- msg="Hi, Opener! \nYou currently have $pr_count Pull Request(s) open with requested reviews (totalling $((pr_count * 2)) required reviews). \nTo help ease the review burden, increase review velocity for older PRs, and improve the equitable distribution of project maintenance tasks across the team, please consider reviewing this list of ways to contribute instead of working on new code contributions: \nhttps://docs.openverse.org/meta/maintainer_tasks.html"
-
- curl \
- "$slack_url" \
- -X POST \
- -H 'Content-Type: application/json' \
- -d '{
- "user": "'"$slack_id"'",
- "message": "'"$msg"'"
- }'
+ id: slack
+ uses: slackapi/[email protected]
+ with:
+ payload: |
+ {
+ "user": "${{ env.slack_id }}",
+ "message": "Hi, Opener! \nYou currently have ${{ env.pr_count }} Pull Request(s) open with requested reviews (totalling $((${{ env.pr_count }} * 2)) required reviews). \nTo help ease the review burden, increase review velocity for older PRs, and improve the equitable distribution of project maintenance tasks across the team, please consider reviewing this list of ways to contribute instead of working on new code contributions: \nhttps://docs.openverse.org/meta/maintainer_tasks.html"
+ }
diff --git a/.github/workflows/pr_ping.yml b/.github/workflows/pr_ping.yml
index 41c8f1adf..1537b458f 100644
--- a/.github/workflows/pr_ping.yml
+++ b/.github/workflows/pr_ping.yml
@@ -15,30 +15,50 @@ jobs:
!startsWith(github.event.pull_request.title, '🔄')
runs-on: ubuntu-latest
env:
- slack_url: ${{ secrets.SLACK_WEBHOOK_URL }}
pr_url: ${{ github.event.pull_request.html_url }}
pr_number: ${{ github.event.pull_request.number }}
pr_title: ${{ github.event.pull_request.title }}
pr_author: ${{ github.event.pull_request.user.login }}
pr_repo: ${{ github.event.pull_request.base.repo.full_name }}
+ SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
+ SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
steps:
- name: Send notification for new PR
if: github.event.action == 'opened'
+ id: slack
+ uses: slackapi/[email protected]
env:
pr_status: ${{ github.event.pull_request.draft && ' draft ' || ' ' }}
pr_icon: ${{ github.event.pull_request.draft && ':pr-draft:' || ':pull-request:' }}
- run: |
- curl \
- "$slack_url" \
- -X POST \
- -H 'Content-Type: application/json' \
- -d '{"text":"New'"$pr_status"'PR opened by '"$pr_author"' in '"$pr_repo"': #'"$pr_number"' - '"$pr_title"'","blocks":[{"type":"section","text":{"type":"mrkdwn","text":"'"$pr_icon"' New'"$pr_status"'PR opened by *'"$pr_author"'* in `'"$pr_repo"'`:\n<'"$pr_url"'|#'"$pr_number"' - '"$pr_title"'>"}}]}'
-
+ with:
+ payload: |
+ {
+ "text": "New \"${{ env.pr_status }}\" PR opened by \"${{ env.pr_author }}\" in \"${{ env.pr_repo }}\": #\"${{ env.pr_number }}\" - \"${{ env.pr_title }}\"",
+ "blocks": [
+ {
+ "type": "section",
+ "text": {
+ "type": "mrkdwn",
+ "text": "\"${{ env.pr_icon }}\" New\"${{ env.pr_status }}\"PR opened by *\"${{ env.pr_author }}\"* in `\"${{ env.pr_repo }}\"`:\n<\"${{ env.pr_url }}\"|#\"${{ env.pr_number }}\" - \"${{ env.pr_title }}\">"
+ }
+ }
+ ]
+ }
- name: Send notification for PR marked ready
if: github.event.action == 'ready_for_review'
- run: |
- curl \
- "$slack_url" \
- -X POST \
- -H 'Content-Type: application/json' \
- -d '{"text":"PR by '"$pr_author"' in '"$pr_repo"' marked ready for review: #'"$pr_number"' - '"$pr_title"'","blocks":[{"type":"section","text":{"type":"mrkdwn","text":":pull-request: PR by *'"$pr_author"'* in `'"$pr_repo"'` marked ready for review:\n<'"$pr_url"'|#'"$pr_number"' - '"$pr_title"'>"}}]}'
+ id: slack-notifications
+ uses: slackapi/[email protected]
+ with:
+ payload: |
+ {
+ "text": "PR by \"${{ env.pr_author }}\" in \"${{ env.pr_repo }}\" marked ready for review: #${{ env.pr_number }} - \"${{ env.pr_title }}\"",
+ "blocks": [
+ {
+ "type": "section",
+ "text": {
+ "type": "mrkdwn",
+ "text": ":pull-request: PR by *${{ env.pr_author }}* in `${{ env.pr_repo }}` marked ready for review:\n<${{ env.pr_url }}|#${{ env.pr_number }} - ${{ env.pr_title }}>"
+ }
+ }
+ ]
+ }