Skip to content

Commit

Permalink
Merge branch 'multi-channel'
Browse files Browse the repository at this point in the history
  • Loading branch information
archive committed Oct 14, 2021
2 parents b396dfa + fb3ee92 commit b8787a5
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 21 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on: [push, issues]
jobs:
slack-notification-with-optional-parameters:
runs-on: ubuntu-20.04
name: Test 1 (Sends message on Push and Issue)
name: Test 1 [ubuntu-20.04]

steps:
- name: Send Slack Message
Expand All @@ -14,7 +14,7 @@ jobs:
with:
slack-bot-user-oauth-access-token: ${{ secrets.SLACK_BOT_USER_OAUTH_ACCESS_TOKEN }}
slack-channel: CPPUV5KU0
slack-text: "Test 1 - With :fire: icon [at locked version]"
slack-text: "Test 1 - :fire:"
slack-optional-icon_emoji: ":fire:"
slack-optional-as_user: false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ on: [push, issues]

jobs:
slack-notification:
runs-on: windows-2019
name: Test 2 (Sends message on Push and Issue)
runs-on: windows-latest
name: Test 2 [windows-latest]

steps:
- name: Send Slack Message
Expand All @@ -14,7 +14,7 @@ jobs:
with:
slack-bot-user-oauth-access-token: ${{ secrets.SLACK_BOT_USER_OAUTH_ACCESS_TOKEN }}
slack-channel: CPPUV5KU0
slack-text: Test 2 - 🤓 With Event name "${{ github.event_name }}" and Repo "${{ github.repository }}" [at mater]
slack-text: Test 2 - 🤓 Event name "${{ github.event_name }}" Repo "${{ github.repository }}"

- name: Result from "Send Slack Message"
run: echo '${{ steps.send-message.outputs.slack-result }}'
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ on: [push, issues]

jobs:
slack-reaction:
runs-on: ubuntu-20.04
name: Test 3 (Sends message on Push and Issue)
runs-on: ubuntu-latest
name: Test 3 [ubuntu-latest]

steps:
- name: Send Slack Message
Expand All @@ -16,7 +16,7 @@ jobs:
slack-function: send-message
slack-bot-user-oauth-access-token: ${{ secrets.SLACK_BOT_USER_OAUTH_ACCESS_TOKEN }}
slack-channel: CPPUV5KU0
slack-text: Test 3 - Message to send a react to [at master]
slack-text: Test 3 - Message to send a react to

- name: Send Slack Message Result
run: echo 'Data - ${{ steps.send-message.outputs.slack-result }}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ on: [push, issues]

jobs:
slack-thread:
runs-on: ubuntu-20.04
name: Test 4 (Sends message on Push and Issue)
runs-on: macos-latest
name: Test 4 [macos-latest]

steps:
- name: Send Slack Message
Expand All @@ -16,7 +16,7 @@ jobs:
slack-function: send-message
slack-bot-user-oauth-access-token: ${{ secrets.SLACK_BOT_USER_OAUTH_ACCESS_TOKEN }}
slack-channel: CPPUV5KU0
slack-text: Test 4 - Message to send thread to [at master]
slack-text: Test 4 - Message to send thread to

- name: Send "Slack Message" Result
run: echo 'Data - ${{ steps.send-message.outputs.slack-result }}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on: [push, issues]
jobs:
slack-update-message:
runs-on: ubuntu-20.04
name: Test 5 (Sends message on Push and Issue)
name: Test 5 [ubuntu-20.04]

steps:
- name: Send Slack Message
Expand All @@ -16,7 +16,7 @@ jobs:
slack-function: send-message
slack-bot-user-oauth-access-token: ${{ secrets.SLACK_BOT_USER_OAUTH_ACCESS_TOKEN }}
slack-channel: CPPUV5KU0
slack-text: Test 5 - Message to update [at master]
slack-text: Test 5 - Message to update

- name: Send Slack Message Result
run: echo 'Data - ${{ steps.send-message.outputs.slack-result }}'
Expand All @@ -30,7 +30,7 @@ jobs:
slack-function: update-message
slack-bot-user-oauth-access-token: ${{ secrets.SLACK_BOT_USER_OAUTH_ACCESS_TOKEN }}
slack-channel: ${{ fromJson(steps.send-message.outputs.slack-result).response.channel }}
slack-update-message-text: Test 5 - Message to update [at master] - updated
slack-update-message-text: Test 5.1 - Message to update - updated
slack-update-message-ts: ${{ fromJson(steps.send-message.outputs.slack-result).response.message.ts }}

- name: Send Slack Reaction To Message Result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on: [push, issues]
jobs:
slack-thread-with-broadcast:
runs-on: ubuntu-20.04
name: Test 6 (Sends message on Push and Issue)
name: Test 6 [ubuntu-20.04]

steps:
- name: Send Slack Message
Expand All @@ -16,7 +16,7 @@ jobs:
slack-function: send-message
slack-bot-user-oauth-access-token: ${{ secrets.SLACK_BOT_USER_OAUTH_ACCESS_TOKEN }}
slack-channel: CPPUV5KU0
slack-text: Test 6 - Message to send thread to [at master]
slack-text: Test 6 - Message to send thread to

- name: Send "Slack Message" Result
run: echo 'Data - ${{ steps.send-message.outputs.slack-result }}'
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/7-slack-notification-multi-channel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: slack-notification

on: [push, issues]

jobs:
slack-notification:
runs-on: windows-2019
name: Test 7 [windows-2019]

steps:
- name: Send Slack Message
uses: archive/github-actions-slack@master
id: send-message
with:
slack-bot-user-oauth-access-token: ${{ secrets.SLACK_BOT_USER_OAUTH_ACCESS_TOKEN }}
slack-channel: CPPUV5KU0,C02HEBQP46T
slack-text: Test 7 - Same message multiple channels

- name: Result from "Send Slack Message"
run: echo '${{ steps.send-message.outputs.slack-result }}'

- name: Results from "Send Slack Message"
run: echo '${{ steps.send-message.outputs.slack-results }}'
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,11 @@ If you want to output or debug the result, add:
run: echo "${{ steps.send-message.outputs.slack-result }}"
```

- `slack-results` (.outputs.slack-results) - Contains an array of all the results when sending to multiple channels. This can be used for following steps like sending a reaction. See [.github/workflows/7-slack-notification-multi-channel.yml](.github/workflows/7-slack-notification-multi-channel.yml)

### Sample Action file with Slack Channel and Text

[.github/workflows/slack-notification.yml](.github/workflows/slack-notification.yml)
[.github/workflows/2-slack-notification.yml](.github/workflows/2-slack-notification.yml)

This will send a Slack message every time someone push, creates pull request or create an issue

Expand Down Expand Up @@ -128,7 +130,7 @@ jobs:

### Sample Action file with Slack optional parameters

[.github/workflows/slack-notification.yml](.github/workflows/slack-notification.yml)
[.github/workflows/2-slack-notification.yml](.github/workflows/2-slack-notification.yml)

```
name: slack-notification-with-optional-parameters
Expand Down Expand Up @@ -165,7 +167,7 @@ To send a thread response you have the same setup as for sending a message, but

### Sample Action file

[.github/workflows/slack-thread.yml](.github/workflows/slack-thread.yml)
[.github/workflows/4-slack-thread.yml](.github/workflows/4-slack-thread.yml)

See `Send Thread Message` part below:

Expand Down Expand Up @@ -235,7 +237,7 @@ jobs:

### Sample Action file with Slack Channel and Text

[.github/workflows/slack-reaction.yml](.github/workflows/slack-reaction.yml)
[.github/workflows/3-slack-reaction.yml](.github/workflows/3-slack-reaction.yml)

This will send a Slack message every time someone push, creates pull request or create an issue, and then, create a reaction to it

Expand Down Expand Up @@ -285,7 +287,7 @@ jobs:

Similar to Add Reaction, but with text instead.

Please see [.github/workflows/slack-update-message.yml](.github/workflows/slack-update-message.yml)
Please see [.github/workflows/5-slack-update-message.yml](.github/workflows/5-slack-update-message.yml)

## How to setup your first Github Action in your repository that will call this Action

Expand Down

0 comments on commit b8787a5

Please sign in to comment.