publish-using-ci-workflow.js — react Source File
Architecture documentation for publish-using-ci-workflow.js, a javascript file in the react codebase.
Entity Profile
Relationship Graph
Source Code
'use strict';
const fetch = require('node-fetch');
const {logPromise} = require('./utils');
const theme = require('./theme');
const CIRCLE_TOKEN = process.env.CIRCLE_CI_API_TOKEN;
if (!CIRCLE_TOKEN) {
console.error(
theme.error(
'Missing required environment variable: CIRCLE_CI_API_TOKEN\n' +
'Grab it here: https://app.circleci.com/settings/user/tokens'
)
);
process.exit(1);
}
function sleep(ms) {
return new Promise(resolve => {
setTimeout(() => resolve(), ms);
});
}
async function getPublishWorkflowID(pipelineID) {
// Since we just created the pipeline in a POST request, the server may 404.
// Try a few times before giving up.
for (let i = 0; i < 20; i++) {
const pipelineWorkflowsResponse = await fetch(
`https://circleci.com/api/v2/pipeline/${pipelineID}/workflow`
);
if (pipelineWorkflowsResponse.ok) {
const pipelineWorkflowsJSON = await pipelineWorkflowsResponse.json();
const workflows = pipelineWorkflowsJSON.items;
if (workflows.length !== 0) {
return workflows[0].id;
}
}
// CircleCI server may be stale. Wait a sec and try again.
await sleep(1000);
}
return null;
}
async function pollUntilWorkflowFinishes(workflowID) {
while (true) {
const workflowResponse = await fetch(
`https://circleci.com/api/v2/workflow/${workflowID}`
);
const workflow = await workflowResponse.json();
switch (workflow.status) {
case 'running':
// Workflow still running. Wait a bit then check again.
await sleep(2000);
continue;
case 'success':
// Publish succeeded! Continue.
return;
case 'not_run':
// ... (89 more lines)
Domain
Subdomains
Source
Frequently Asked Questions
What does publish-using-ci-workflow.js do?
publish-using-ci-workflow.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Entrypoint subdomain.
What functions are defined in publish-using-ci-workflow.js?
publish-using-ci-workflow.js defines 4 function(s): getPublishWorkflowID, main, pollUntilWorkflowFinishes, sleep.
Where is publish-using-ci-workflow.js in the architecture?
publish-using-ci-workflow.js is located at scripts/release/publish-using-ci-workflow.js (domain: BabelCompiler, subdomain: Entrypoint, directory: scripts/release).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free