Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Fix failure in "Re-run Flaky Workflows" workflow (#78135)

Chris Vandoodewaard71d66af5a2d8
diff --git a/.github/workflows/rerun-workflows.yml b/.github/workflows/rerun-workflows.yml
index bc8670bbc99..7511f1db118 100644
--- a/.github/workflows/rerun-workflows.yml
+++ b/.github/workflows/rerun-workflows.yml
@@ -35,12 +35,10 @@ jobs:
- name: Prepare release scripts
uses: ./.github/actions/prepare-release-scripts
- - uses: actions/[email protected]
- with:
- node-version: lts/Jod # 22.x.x
- - run: npm install @slack/web-api
- name: Trigger a re-run
uses: actions/github-script@v9
+ env:
+ SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
with:
script: | # js
const MAX_ATTEMPTS = 1;
@@ -52,8 +50,6 @@ jobs:
const AUTHOR_LOGIN = process.env.AUTHOR_LOGIN;
const BRANCH = process.env.BRANCH_NAME;
- const { mentionUserByGithubLogin } = require('${{ github.workspace }}/release/dist/index.cjs');
-
if (ATTEMPT <= MAX_ATTEMPTS) {
try {
await github.rest.actions.reRunWorkflowFailedJobs({
@@ -70,8 +66,7 @@ jobs:
}
} else if (!BRANCH.includes('backport-')) {
// notify slack of repeated failure
- const { WebClient } = require('@slack/web-api');
- const slack = new WebClient('${{ secrets.SLACK_BOT_TOKEN }}');
+ const { mentionUserByGithubLogin, sendSlackMessage } = require('${{ github.workspace }}/release/dist/index.cjs');
// find out which jobs failed
const { owner, repo } = context.repo;
@@ -102,9 +97,9 @@ jobs:
]
}));
- await slack.chat.postMessage({
- channel: 'engineering-ci',
- text: 'Failing tests',
+ await sendSlackMessage({
+ channelName: 'engineering-ci',
+ message: 'Failing tests',
blocks: [
{
"type": "header",
diff --git a/release/src/slack.ts b/release/src/slack.ts
index fd509383f8c..f18644a9113 100644
--- a/release/src/slack.ts
+++ b/release/src/slack.ts
@@ -2,6 +2,7 @@ import 'dotenv/config';
import fs from 'fs';
import { WebClient } from '@slack/web-api';
+import type { Block, KnownBlock, MessageAttachment } from '@slack/web-api';
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
import fetch from 'node-fetch';
@@ -162,10 +163,17 @@ export async function sendPreReleaseStatus({
});
}
-export function sendSlackMessage({ channelName = SLACK_CHANNEL_NAME, message }: { channelName?: string, message: string }) {
+export function sendSlackMessage({ channelName = SLACK_CHANNEL_NAME, message, blocks, attachments }: {
+ channelName?: string,
+ message: string,
+ blocks?: (Block | KnownBlock)[],
+ attachments?: MessageAttachment[],
+}) {
return slack.chat.postMessage({
channel: channelName,
text: message,
+ blocks,
+ attachments,
});
}