Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option: noRetry for slack client #76

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
12.9.0
16.14.2
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ When used with the `pull_request` event, a link to the originating pull request

<img src="docs/pr.png" alt="Screenshot of the pull_request event" width="540">

If you want no retry for slack client, you can indicate with `noRetry: true` in `with` (if not, it's `tenRetriesInAboutThirtyMinutes` by default, you can check doc in [slack web api](https://www.npmjs.com/package/@slack/web-api))

### Updating an Existing Message

If you need to send multiple Slack build updates and you prefer to update a single message instead of posting multiple messages, you can pass a `message_id` to future steps.
Expand Down
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

name: 'Slack Notify Build'
description: 'Report GitHub Actions build status on Slack'
branding:
Expand All @@ -20,9 +21,12 @@ inputs:
message_id:
description: 'The ID of the existing Slack message to update.'
required: false
noRetry:
description: 'No retry if error'
required: false
outputs:
message_id:
description: 'The unique timestamp identifier of the Slack message sent'
runs:
using: 'node12'
using: 'node16'
main: 'dist/index.js'
3 changes: 2 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,8 @@ const { buildSlackAttachments, formatChannelName } = __webpack_require__(543);
const color = core.getInput('color');
const messageId = core.getInput('message_id');
const token = process.env.SLACK_BOT_TOKEN;
const slack = new WebClient(token);
const noRetry = core.getInput('noRetry');
const slack = new WebClient(token, noRetry ? { retryConfig: { retries: 0 } } : undefined);

if (!channel && !core.getInput('channel_id')) {
core.setFailed(`You must provider either a 'channel' or a 'channel_id'.`);
Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const { buildSlackAttachments, formatChannelName } = require('./src/utils');
const color = core.getInput('color');
const messageId = core.getInput('message_id');
const token = process.env.SLACK_BOT_TOKEN;
const slack = new WebClient(token);
const noRetry = core.getInput('noRetry');
const slack = new WebClient(token, noRetry ? { retryConfig: { retries: 0 } } : undefined);

if (!channel && !core.getInput('channel_id')) {
core.setFailed(`You must provider either a 'channel' or a 'channel_id'.`);
Expand Down