Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace cURL to Slack with slackapi/slack-github-action #3461

Closed
dhruvkb opened this issue Dec 5, 2023 · 2 comments · Fixed by #3577
Closed

Replace cURL to Slack with slackapi/slack-github-action #3461

dhruvkb opened this issue Dec 5, 2023 · 2 comments · Fixed by #3577
Assignees
Labels
🤖 aspect: dx Concerns developers' experience with the codebase ✨ goal: improvement Improvement to an existing user-facing feature good first issue New-contributor friendly help wanted Open to participation from the community 🟩 priority: low Low priority and doesn't need to be rushed 🧱 stack: mgmt Related to repo management and automations 🔧 tech: github actions Involves Github Actions

Comments

@dhruvkb
Copy link
Member

dhruvkb commented Dec 5, 2023

Problem

The following workflows make Slack API calls using a cURL request.

  • 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"'>"}}]}'
  • 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"'"
    }'
  • 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"'>"}}]}'
  • 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"'>"}}]}'

Description

A better approach is to use the (official?) Slack API action slackapi/slack-github-action@v1.23.0 by means of technique 3 i.e. incoming webhooks. These workflows can be coverted to that actions making them more maintainable because cURL and Bash (and especially together) can be notoriously hard to understand and make changes to.

@dhruvkb dhruvkb added good first issue New-contributor friendly help wanted Open to participation from the community 🟩 priority: low Low priority and doesn't need to be rushed ✨ goal: improvement Improvement to an existing user-facing feature 🤖 aspect: dx Concerns developers' experience with the codebase 🧱 stack: mgmt Related to repo management and automations 🔧 tech: github actions Involves Github Actions labels Dec 5, 2023
@The5cheduler
Copy link
Contributor

I would like to contribute to this!
Please assign it to me.

@The5cheduler
Copy link
Contributor

The5cheduler commented Dec 21, 2023

Hey @AetherUnbound , I think current version of slackapi/slack-github-action is 1.24.0. I have used that in current change, please let me know if it need ot me 1.23.0 for any particular reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖 aspect: dx Concerns developers' experience with the codebase ✨ goal: improvement Improvement to an existing user-facing feature good first issue New-contributor friendly help wanted Open to participation from the community 🟩 priority: low Low priority and doesn't need to be rushed 🧱 stack: mgmt Related to repo management and automations 🔧 tech: github actions Involves Github Actions
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants