Skip to content

Commit

Permalink
add slack notif
Browse files Browse the repository at this point in the history
  • Loading branch information
sainthiago committed Oct 19, 2023
1 parent 9362b2a commit 8188737
Show file tree
Hide file tree
Showing 6 changed files with 194 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/pr-approved.yml
@@ -0,0 +1,26 @@
name: Slack P/R Approved notification

on:
pull_request_review:
types: [submitted]

jobs:
approved:
if: github.event.review.state == 'approved'
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

# Runs the Slack webhook notify action to send a notification
- name: Slack Notify
uses: slackapi/slack-github-action@v1.24.0
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
with:
channel-id: 'github-flows'
payload: |
{
"text": "✅ ᴀᴘᴘʀᴏᴠᴇᴅ : <${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}> was approved by ${{ github.actor }}"
}
27 changes: 27 additions & 0 deletions .github/workflows/pr-merged.yml
@@ -0,0 +1,27 @@
name: Slack P/R Merged notification

on:
pull_request:
types:
- closed

jobs:
if_merged:
if: github.event.pull_request.merged
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

# Runs the Slack webhook notify action to send a notification
- name: Slack Notify
uses: slackapi/slack-github-action@v1.24.0
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
with:
channel-id: 'github-flows'
payload: |
{
"text": "⤵️ ᴍᴇʀɢᴇᴅ : <${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}>"
}
26 changes: 26 additions & 0 deletions .github/workflows/pr-open.yml
@@ -0,0 +1,26 @@
name: Slack P/R Request OPEN

on:
pull_request_review:
types: [submitted]

jobs:
changesrequested:
if: github.event.review.state == 'changes_requested'
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

# Runs the Slack webhook notify action to send a notification
- name: Slack Notify
uses: slackapi/slack-github-action@v1.24.0
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
with:
channel-id: 'github-flows'
payload: |
{
"text": " ➡️ ᴏᴘᴇɴ : <${{ github.event.pull_request.html_url }}|{{ github.event.pull_request.title }}> \nAuthor: ${{ github.actor }}"
}
50 changes: 50 additions & 0 deletions .github/workflows/pr-push.yml
@@ -0,0 +1,50 @@
name: Slack Push Notification

on:
pull_request:
types: [opened, reopened, synchronize]

jobs:
notify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Find Pull Request
id: find_pr
run: |
# Get the pull request number and title
pr_number=$(jq --raw-output .number $GITHUB_EVENT_PATH)
pr_title=$(jq --raw-output .pull_request.title $GITHUB_EVENT_PATH)
pr_html_url=$(jq --raw-output .pull_request.html_url $GITHUB_EVENT_PATH)
# Set the output variables
echo "::set-output name=pull_request_number::$pr_number"
echo "::set-output name=pull_request_title::$pr_title"
echo "::set-output name=pull_request_html_url::$pr_html_url"
- name: Checkout Code
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }}

- name: Get Latest Commit Message and URL
id: commit_info
run: |
COMMIT_MESSAGE=$(git log --format=%B -n 1)
COMMIT_URL=$(git log --format=%H -n 1)
NUM_FILES_CHANGED=$(git --no-pager diff --name-only origin/main...${{ github.event.pull_request.base.ref }} | wc -l)
echo ::set-output name=num_files_changed::$NUM_FILES_CHANGED
echo ::set-output name=commit_message::$COMMIT_MESSAGE
echo ::set-output name=commit_url::https://github.com/${{ github.repository }}/commit/${COMMIT_URL}
echo ::set-output name=files_url::https://github.com/${{ github.repository }}/pull/${{ steps.find_pr.outputs.pull_request_number }}/files
- name: Slack Notify
uses: slackapi/slack-github-action@v1.24.0
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
with:
channel-id: 'github-flows'
payload: |
{
"text": "⬆️ Push on branch: <https://github.com/mintbase/mintbase-js/tree/${{ github.head_ref }}|${{ github.head_ref }}>\nPR: [mintbase-js] <${{ github.event.pull_request.html_url }}|#${{ steps.find_pr.outputs.pull_request_number }} ${{ github.event.pull_request.title }}>\nCommit: <${{ steps.commit_info.outputs.commit_url }} | ${{ steps.commit_info.outputs.commit_message }}>\nAuthor: ${{ github.actor }}"
}
26 changes: 26 additions & 0 deletions .github/workflows/pr-request-changes.yml
@@ -0,0 +1,26 @@
name: Slack P/R Request Changes notification

on:
pull_request_review:
types: [submitted]

jobs:
changesrequested:
if: github.event.review.state == 'changes_requested'
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

# Runs the Slack webhook notify action to send a notification
- name: Slack Notify
uses: slackapi/slack-github-action@v1.24.0
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
with:
channel-id: 'github-flows'
payload: |
{
"text": "♻️ [REQUESTED CHANGES] : <${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}>\nBy:${{ github.actor }} "
}
39 changes: 39 additions & 0 deletions .github/workflows/pr-review.yml
@@ -0,0 +1,39 @@
name: Slack P/R Review and Comment notification

on:
pull_request_review:
types: [submitted]
issue_comment:
types: [created]

jobs:
notify:
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

# Determine the type of event (review or comment) and set the notification message accordingly
- name: Set Notification Message
id: set_message
run: |
if [[ -n "${{ github.event.pull_request_review }}" ]]; then
echo "Review: ✉️ [${{ github.event.pull_request.title }}](${{ github.event.pull_request.html_url }}) - ${{ github.event.review.user.login }} - ${{ github.event.review.state }}"
echo ::set-output name=message::"Review: ✉️ [${{ github.event.pull_request.title }}](${{ github.event.pull_request.html_url }}) - ${{ github.event.review.user.login }} - ${{ github.event.review.state }}"
elif [[ -n "${{ github.event.issue_comment }}" ]]; then
echo "Comment: 💬 [${{ github.event.pull_request.title }}](${{ github.event.pull_request.html_url }}) - ${{ github.event.comment.user.login }}"
echo ::set-output name=message::"Comment: 💬 [${{ github.event.pull_request.title }}](${{ github.event.pull_request.html_url }}) - ${{ github.event.comment.user.login }}"
fi
# Runs the Slack webhook notify action to send a notification
- name: Slack Notify
uses: slackapi/slack-github-action@v1.24.0
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
with:
channel-id: 'github-flows'
payload: |
{
"text": ${{ steps.set_message.outputs.message }}
}

0 comments on commit 8188737

Please sign in to comment.