Created
December 11, 2019 22:38
-
-
Save christianhaller3000/8cd32b31214fbe93393972e5a2e6250e to your computer and use it in GitHub Desktop.
get circleci workflow name by api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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