Skip to content

Commit

Permalink
Merge pull request #29 from svinstech/dev2
Browse files Browse the repository at this point in the history
Made user-tagging and user-group-tagging more consistent and straightforward.
  • Loading branch information
KellenKincaid authored Oct 19, 2023
2 parents 98b8d1a + 3471532 commit d2ea546
Show file tree
Hide file tree
Showing 13 changed files with 334 additions and 222 deletions.
17 changes: 0 additions & 17 deletions .circleci/test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ jobs:
docker:
- image: cimg/base:current
steps:
- slack-notifier/gather-slack-ids:
slack-bot-token: NOTIFIER_BOT_TOKEN
- slack-notifier/build-status-notification:
header: Tag test
additional-text: "Testing out tagging Kellen Kincaid & SDET group -> @kellen_kincaid !sdet"
Expand All @@ -97,18 +95,6 @@ jobs:
header: Non-existent tag test
additional-text: "Testing out fake tags -> @mashed_potatoes !dragon_ball_z"
channel-webhook-environment-variables: WEBHOOK_KELLEN_KINCAID
test-auto-ping:
docker:
- image: cimg/base:current
steps:
- slack-notifier/gather-slack-ids:
slack-bot-token: NOTIFIER_BOT_TOKEN
- slack-notifier/identify-build-triggerer:
circle-token: CIRCLECI_PERSONAL_ACCESS_TOKEN
- slack-notifier/build-status-notification:
header: Auto-ping test result
additional-text: ${BUILD_TRIGGERER}
channel-webhook-environment-variables: WEBHOOK_KELLEN_KINCAID



Expand All @@ -135,8 +121,6 @@ workflows:
filters: *filters
- generate-slack-id-lookup-table:
filters: *filters
- test-auto-ping:
filters: *filters
- orb-tools/pack:
filters: *filters
- orb-tools/publish:
Expand All @@ -154,7 +138,6 @@ workflows:
- send-no-message-success
- send-message-success
- generate-slack-id-lookup-table
- test-auto-ping
context: orb-publishing
filters:
branches:
Expand Down
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ orb.yml
slackIds.json
slackUserInfo.json
slackGroupInfo.json
**/slackData
deleteme*
temporary*
**/dist
**/node_modules
.env
.env
**/oldCommands
**/generate_slack_id_lookup_table.sh
**/slackData
24 changes: 8 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,34 @@ Here are some examples:
job-name
docker:
- image: cimg/base:current
run:
- command |
echo "export STRING_INTERPOLATION='some text'">>"$BASH_ENV"
steps:
- slack-notifier/send-slack-message:
header: A header for your message.
message: The message to send. You may also use ${String} ${interpolation} with environment variables.
message: The message to send. You may also use ${STRING_INTERPOLATION}.
channel-webhook-environment-variables: SLACK_WEBHOOK_1 SLACK_WEBHOOK_2
job-name-2
docker:
- image: cimg/base:current
steps:
- slack-notifier/gather-slack-ids:
slack-bot-token: NOTIFIER_BOT_TOKEN
- slack-notifier/build-status-notification:
header: A header for your message.
pass-text: Tests passed! :checkmark:
fail-text: Failures detected! !slack-group-handle @slack-user-handle
fail-text: Failures detected! Tag a group like this: !sdet. Tag a user like this: @kellen_kincaid
when: always
additional-text: Any other text you want to include.
channel-webhook-environment-variables: SLACK_WEBHOOK
channel-webhook-environment-variables: SLACK_WEBHOOK_1

#### TAGGING:
If you're going to tag a user or user group, you must first call the command `gather-slack-ids`, as seen above in `job-name-2`.
Explained below is how to obtain the value for its `slack-bot-token` parameter.


### WEBHOOKS & TOKENS
### WEBHOOKS

This orb requires that the following be added as CircleCI environment variables:
* Slack webhooks for the message recipients.
- The Slack webhook environment variable(s) must be used as the input for the `channel-webhook-environment-variables` argument of either the `send-slack-message` command or the `build-status-notification` command.
* The "Bot User OAuth Token" **(only if you intend to tag a user or a user group)**.
- The Bot User OAuth Token environment variable must be used as the input for the `slack-bot-token` argument of the `gather-slack-ids` command.

#### Obtaining a Slack webhook or a Bot User OAuth Token
#### Obtaining a Slack webhook
You'll need access to a Slack app.
Here are 2 ways to do this:

Expand All @@ -59,9 +54,6 @@ As of June, 2023, some Slack admins include: Yvonne Medellin & Cody Carter.
##### Webhooks
To get a Slack webhook, navigate into the Slack app and go to the **Incoming Webhooks** section (under **Features**). Click the **Activate** button if the section is inactive.
From there, you can add new webhooks, or copy existing ones.

##### Bot User OAuth Token
To get the **Bot User OAuth Token**, navigate into the Slack app and go to the **OAuth & Permissions** section (under **Features**). From there, the **Bot User OAuth Token** will be under the **OAuth Tokens for Your Workspace** header. If you made your own Slack app, then you'll have to generate a new **Bot User OAuth Token**.

---

Expand Down
37 changes: 0 additions & 37 deletions src/commands/gather-slack-ids.yml

This file was deleted.

16 changes: 0 additions & 16 deletions src/commands/identify-build-triggerer.yml

This file was deleted.

4 changes: 4 additions & 0 deletions src/commands/send-slack-message.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ parameters:
enum: ["always", "on_fail", "on_success"]
description: When to send the notification.
steps:
- run:
when: <<parameters.when>>
name: Generate Slack ID lookup table
command: <<include(scripts/create_slack_id_lookup_table.sh)>>
- run:
when: <<parameters.when>>
environment:
Expand Down
2 changes: 0 additions & 2 deletions src/examples/example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ usage:
docker:
- image: cimg/base:current
steps:
- slack-notifier/gather-slack-ids:
slack-bot-token: NOTIFIER_BOT_TOKEN
- slack-notifier/send-slack-message:
header: TESTING SLACK-NOTIFICATION ORB - Message that tags a user
message: "Tagging @kellen_kincaid"
Expand Down
Loading

0 comments on commit d2ea546

Please sign in to comment.