Skip to content

Instantly share code, notes, and snippets.

@christianhaller3000
Created December 11, 2019 22:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christianhaller3000/8cd32b31214fbe93393972e5a2e6250e to your computer and use it in GitHub Desktop.
Save christianhaller3000/8cd32b31214fbe93393972e5a2e6250e to your computer and use it in GitHub Desktop.
get circleci workflow name by api
/* eslint-disable import/no-extraneous-dependencies */
const fetch = require("node-fetch");
const log = require("debug")("app:circleci");
module.exports = async ({ circleToken, workflowId }) => {
// wait for https://ideas.circleci.com/ideas/CCI-I-295
const url = `https://circleci.com/api/v2/workflow/${workflowId}?circle-token=${circleToken}`;
// trigger api with node-fetch
const { name } = await (
await fetch(url, {
headers: {
"Content-Type": "application/json"
}
})
).json();
log(circleToken);
log("workflow id: %s", workflowId);
log("workflow name: %s", name);
return name;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment