Skip to content

Commit

Permalink
Bump @slack/web-api from 6.8.1 to 7.3.1 (#122)
Browse files Browse the repository at this point in the history
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Nick Amoscato <[email protected]>
dependabot[bot] and namoscato authored Jul 18, 2024
1 parent 72ebdc4 commit abc896a
Showing 9 changed files with 46,778 additions and 43,946 deletions.
90,275 changes: 46,541 additions & 43,734 deletions dist/index.js

Large diffs are not rendered by default.

114 changes: 81 additions & 33 deletions dist/licenses.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

246 changes: 101 additions & 145 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@
"@actions/core": "^1.10.1",
"@actions/github": "^6.0.0",
"@octokit/webhooks-types": "^7.5.1",
"@slack/web-api": "^6.8.1",
"@slack/web-api": "^7.3.1",
"date-fns": "^2.30.0"
},
"devDependencies": {
6 changes: 3 additions & 3 deletions src/github/getStageMessage.ts
Original file line number Diff line number Diff line change
@@ -6,8 +6,8 @@ import {getContextBlock} from './getContextBlock'
import {createMessage, emojiFromStatus} from './message'
import {
JobStatus,
Message,
OctokitClient,
StageMessage,
Text,
isCompletedJobStep,
isSuccessful
@@ -28,15 +28,15 @@ export async function getStageMessage({
status,
now,
author
}: Dependencies): Promise<Message> {
}: Dependencies): Promise<StageMessage> {
const text = getText(status)

const duration = await computeDuration(octokit, now)
const contextBlock = getContextBlock(duration)

return {
...createMessage({text, contextBlock, author}),
reply_broadcast: !isSuccessful(status)
successful: isSuccessful(status)
}
}

10 changes: 8 additions & 2 deletions src/github/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type {GitHub} from '@actions/github/lib/utils'
import type {Endpoints} from '@octokit/types'
import type {KnownBlock} from '@slack/web-api'
import type {PostMessageArguments} from '../slack/types'

export type OctokitClient = InstanceType<typeof GitHub>

@@ -10,11 +9,18 @@ export interface Text {
mrkdwn: string
}

export interface Message extends PostMessageArguments {
export interface Message {
icon_url: string | undefined
username: string | undefined
unfurl_links: boolean
text: string
blocks: KnownBlock[]
}

export interface StageMessage extends Message {
successful: boolean
}

/**
* @see https://docs.github.com/en/actions/learn-github-actions/contexts#job-context
*/
12 changes: 9 additions & 3 deletions src/postMessage.ts
Original file line number Diff line number Diff line change
@@ -34,26 +34,32 @@ export async function postMessage({

const status = getInput('status', {required: true})
const now = new Date()
const stageMessage = await getStageMessage({octokit, status, now, author})
const {successful, ...stageMessage} = await getStageMessage({
octokit,
status,
now,
author
})

info(`Posting stage message in thread: ${threadTs}`)
await slack.postMessage({
...stageMessage,
reply_broadcast: !successful,
thread_ts: threadTs
})

const conclusion = 'true' === getInput('conclusion')

if (conclusion || !isSuccessful(status)) {
info(`Updating summary message: ${status}`)
const message = await getSummaryMessage({
const summaryMessage = await getSummaryMessage({
octokit,
options: {status, threadTs, now},
author
})

await slack.updateMessage({
...message,
...summaryMessage,
ts: threadTs
})
}
2 changes: 1 addition & 1 deletion src/slack/SlackClient.ts
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ export class SlackClient {
*/
async getRealUsers(): Promise<Member[] | null> {
try {
const {members} = await this.web.users.list()
const {members} = await this.web.users.list({})

if (!members) {
throw new Error('Error fetching users')
57 changes: 33 additions & 24 deletions src/slack/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import type {
ChatPostMessageArguments,
ChatUpdateArguments,
UsersListResponse
} from '@slack/web-api'
import type {KnownBlock, UsersListResponse} from '@slack/web-api'

export type Member = NonNullable<UsersListResponse['members']>[0]

@@ -35,25 +31,38 @@ export interface Image {
image_url: string
}

export type PostMessageArguments = Omit<
RemoveIndex<ChatPostMessageArguments>,
'channel'
>
export type PostMessageArguments = MessageArguments & ReplyInThread

export type UpdateMessageArguments = Omit<
RemoveIndex<ChatUpdateArguments>,
'channel'
>
export interface UpdateMessageArguments extends MessageArguments {
/** Timestamp of the message. */
ts: string
}

/**
* Remove `WebAPICallOptions` index signature from Slack argument types.
*
* @see https://stackoverflow.com/a/51956054
*/
type RemoveIndex<T> = {
[K in keyof T as string extends K
? never
: number extends K
? never
: K]: T[K]
/** Stricter and compatible with `ChatPostMessageArguments` / `ChatUpdateArguments` */
interface MessageArguments {
/** URL to an image to use as the icon for this message */
icon_url: string | undefined
/** Set your bot's username */
username: string | undefined
/** Pass `true` to enable unfurling of primarily text-based content. */
unfurl_links: boolean
/** Fallback notification text. */
text: string
/** An array of structured Blocks. */
blocks: KnownBlock[]
}

/** Copied from `@slack/web-api` source types */
type ReplyInThread = WithinThreadReply | BroadcastedThreadReply

interface WithinThreadReply extends Partial<ThreadTS> {
reply_broadcast?: false
}

interface BroadcastedThreadReply extends ThreadTS {
reply_broadcast: true
}

interface ThreadTS {
thread_ts: string
}

0 comments on commit abc896a

Please sign in to comment.