Skip to content

Commit

Permalink
slack message
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinMind committed Feb 14, 2025
1 parent a9dcc71 commit d441a0d
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/actions/slack/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: 'Send Slack Message'
description: 'Sends a message to a specified Slack channel'

inputs:
slack_token:
description: 'Slack Bot User OAuth Token'
required: true
message:
description: 'Message to send to Slack'
required: true
channel_id:
description: 'Slack Channel ID to send message to'
required: true

runs:
using: 'composite'
steps:
- name: Post plain text message to a Slack channel
uses: slackapi/slack-github-action@v2.0.0
with:
method: chat.postMessage
token: ${{ inputs.slack_token }}
payload: |
channel: ${{ inputs.channel_id }}
text: ${{ inputs.message }}
31 changes: 31 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Test Actions on Push

on:
push:
workflow_dispatch:
inputs:
message:
description: 'Message to send to Slack'
required: true
default: 'Hello, world!'
channel_id:
description: 'Slack Channel ID to send message to'
required: true

jobs:
test:
runs-on: ubuntu-latest

env:
slack_token: ${{ secrets.SLACK_BOT_TOKEN }}
message: ${{ inputs.message }}
channel_id: ${{ inputs.channel_id || secrets.SLACK_CHANNEL_ID }}

steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Send Slack Message
uses: ./.github/actions/slack
with:
message: ${{ inputs.message }}
channel_id: ${{ inputs.channel_id }}

0 comments on commit d441a0d

Please sign in to comment.