-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Slack error handling and remove use of deprecated API method (#141)
* fix: deprecated api methods and error handling * fix test * add README * minor fix * Update gokart/slack/README.md apply review suggestion Co-authored-by: K.O. <[email protected]> * add slack_notification document on doc directory Co-authored-by: hirohito-sasakawa <[email protected]> Co-authored-by: K.O. <[email protected]>
- Loading branch information
1 parent
558a03f
commit 249b0b6
Showing
5 changed files
with
138 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
gokart Slack notification | ||
========================= | ||
|
||
Prerequisites | ||
------------- | ||
|
||
Prepare following environmental variables: | ||
|
||
.. code:: sh | ||
export SLACK_TOKEN=xoxb-your-token // should use token starts with "xoxb-" (bot token is preferable) | ||
export SLACK_CHANNEL=channel-name // not "#channel-name", just "channel-name" | ||
A Slack bot token can obtain from `here <https://api.slack.com/apps>`_. | ||
|
||
A bot token needs following scopes: | ||
|
||
- `channels:read` | ||
- `chat:write` | ||
- `files:write` | ||
|
||
More about scopes are `here <https://api.slack.com/scopes>`_. | ||
|
||
Implement Slack notification | ||
---------------------------- | ||
|
||
Write following codes pass arguments to your gokart workflow. | ||
|
||
.. code:: python | ||
cmdline_args = sys.argv[1:] | ||
if 'SLACK_CHANNEL' in os.environ: | ||
cmdline_args.append(f'--SlackConfig-channel={os.environ["SLACK_CHANNEL"]}') | ||
if 'SLACK_TO_USER' in os.environ: | ||
cmdline_args.append(f'--SlackConfig-to-user={os.environ["SLACK_TO_USER"]}') | ||
gokart.run(cmdline_args) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters