Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
refactor: removing the details about PR and leaving storybook build link
Browse files Browse the repository at this point in the history
  • Loading branch information
georgewrmarshall committed Jan 17, 2024
1 parent b9528bb commit 4b56da5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 160 deletions.
3 changes: 0 additions & 3 deletions .circleci/scripts/highlights/README.md

This file was deleted.

31 changes: 0 additions & 31 deletions .circleci/scripts/highlights/index.js

This file was deleted.

91 changes: 0 additions & 91 deletions .circleci/scripts/highlights/storybook.js

This file was deleted.

43 changes: 8 additions & 35 deletions .circleci/scripts/metamaskbot-build-announce.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
#!/usr/bin/env node
const { promises: fs } = require('fs');
const path = require('path');
const fetch = require('node-fetch');
const { getHighlights } = require('./highlights');

start().catch((error) => {
console.error(error);
process.exit(1);
});

async function start() {
const { GITHUB_COMMENT_TOKEN, CIRCLE_PULL_REQUEST } = process.env;
console.log('CIRCLE_PULL_REQUEST', CIRCLE_PULL_REQUEST);
const { CIRCLE_SHA1 } = process.env;
console.log('CIRCLE_SHA1', CIRCLE_SHA1);
const { CIRCLE_BUILD_NUM } = process.env;
console.log('CIRCLE_BUILD_NUM', CIRCLE_BUILD_NUM);
const { CIRCLE_WORKFLOW_JOB_ID } = process.env;
console.log('CIRCLE_WORKFLOW_JOB_ID', CIRCLE_WORKFLOW_JOB_ID);
const {
GITHUB_COMMENT_TOKEN,
CIRCLE_PULL_REQUEST,
CIRCLE_SHA1,
CIRCLE_WORKFLOW_JOB_ID,
} = process.env;

if (!CIRCLE_PULL_REQUEST) {
console.warn(`No pull request detected for commit "${CIRCLE_SHA1}"`);
Expand All @@ -31,33 +26,11 @@ async function start() {
const storybookUrl = `${BUILD_LINK_BASE}/storybook/index.html`;
const storybookLink = `<a href="${storybookUrl}">Storybook</a>`;

// link to artifacts
const allArtifactsUrl = `https://circleci.com/gh/MetaMask/design-tokens/${CIRCLE_BUILD_NUM}#artifacts/containers/0`;

const contentRows = [
`storybook: ${storybookLink}`,
`<a href="${allArtifactsUrl}">all artifacts</a>`,
];
const hiddenContent = `<ul>${contentRows
.map((row) => `<li>${row}</li>`)
.join('\n')}</ul>`;
const exposedContent = `Builds ready [${SHORT_SHA1}]`;
const artifactsBody = `<details><summary>${exposedContent}</summary>${hiddenContent}</details>\n\n`;

let commentBody = artifactsBody;
try {
const highlights = await getHighlights({ artifactBase: BUILD_LINK_BASE });
if (highlights) {
const highlightsBody = `### highlights:\n${highlights}\n`;
commentBody += highlightsBody;
}
} catch (error) {
console.error(`Error constructing highlight results: '${error}'`);
}
const commentBody = `Builds ready [${SHORT_SHA1}]\n\nStorybook: ${storybookLink}`;

const JSON_PAYLOAD = JSON.stringify({ body: commentBody });
const POST_COMMENT_URI = `https://api.github.com/repos/metamask/design-tokens/issues/${CIRCLE_PR_NUMBER}/comments`;
console.log(`Announcement:\n${commentBody}`);

console.log(`Posting to: ${POST_COMMENT_URI}`);

const response = await fetch(POST_COMMENT_URI, {
Expand Down

0 comments on commit 4b56da5

Please sign in to comment.