Skip to content

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

don't tag author on Slack since Github doesn't populate author login info (#78569)

Chris Vandoodewaardcfcf9fc18b66
diff --git a/.github/workflows/rerun-workflows.yml b/.github/workflows/rerun-workflows.yml
index 7511f1db118..7def4e0da56 100644
--- a/.github/workflows/rerun-workflows.yml
+++ b/.github/workflows/rerun-workflows.yml
@@ -46,8 +46,8 @@ jobs:
const FAILED_RUN_URL = "${{ github.event.workflow_run.html_url }}";
const FAILED_RUN_NAME = "${{ github.event.workflow_run.name }}";
const BREAKING_COMMIT = "${{ github.event.workflow_run.head_sha }}";
- const AUTHOR = process.env.AUTHOR_NAME;
- const AUTHOR_LOGIN = process.env.AUTHOR_LOGIN;
+ let AUTHOR = process.env.AUTHOR_NAME;
+ let AUTHOR_LOGIN = process.env.AUTHOR_LOGIN;
const BRANCH = process.env.BRANCH_NAME;
if (ATTEMPT <= MAX_ATTEMPTS) {
@@ -86,6 +86,24 @@ jobs:
return;
}
+ // the workflow_run payload omits the github login when the commit
+ // author isn't matched to a github account, so look it up from
+ // the commit itself
+ if (!AUTHOR_LOGIN) {
+ try {
+ const { data: commit } = await github.rest.repos.getCommit({
+ owner,
+ repo,
+ ref: BREAKING_COMMIT,
+ });
+
+ AUTHOR_LOGIN = commit.author?.login ?? '';
+ AUTHOR = AUTHOR || commit.commit?.author?.name || '';
+ } catch (error) {
+ console.log(`Could not look up the author of ${BREAKING_COMMIT}: ${error.message}`);
+ }
+ }
+
const failedJobsList = failedJobs.map(job => ({
"type": "rich_text_section",
"elements": [
diff --git a/release/src/slack.ts b/release/src/slack.ts
index f18644a9113..63a96a7cb8b 100644
--- a/release/src/slack.ts
+++ b/release/src/slack.ts
@@ -24,7 +24,7 @@ export function mentionUserByGithubLogin(githubLogin?: string | null) {
if (githubLogin && githubLogin in githubSlackMap) {
return `<@${githubSlackMap[githubLogin]}>`;
}
- return `@${githubLogin ?? 'unassigned'}`;
+ return githubLogin ? `@${githubLogin}` : '@unassigned';
}
export function mentionSlackTeam(teamName: string) {