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

Enhancements to CircleCI Script and Storybook Build #583

Merged
merged 2 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading