Last active
November 21, 2019 21:08
-
-
Save JulienKode/e0dda818893d6fa2595e04223c4d8777 to your computer and use it in GitHub Desktop.
CircleCi example of setup for monorepo: https://tech.julienkarst.com/how-to-setup-circleci-inside-a-monorepo | We will see how to use the CircleCI API to trigger workflow
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
const fetch = require('node-fetch'); | |
const { exec } = require('child_process'); | |
const modules = ['core', 'components']; | |
exec('npx lerna changed --all', (error, stdout) => { | |
modules.forEach(name => { | |
if (!stdout.includes(name)) return; | |
const params = { | |
parameters: { | |
[name]: true, | |
trigger: false, | |
}, | |
branch: process.env.CIRCLE_BRANCH, | |
}; | |
fetch( | |
`https://circleci.com/api/v2/project/github/${process.env.CIRCLE_PROJECT_USERNAME}/${process.env.CIRCLE_PROJECT_REPONAME}/pipeline`, | |
{ | |
body: JSON.stringify(params), | |
headers: { | |
Authorization: `Basic ${Buffer.from( | |
process.env.CIRCLE_TOKEN | |
).toString('base64')}`, | |
'Content-Type': 'application/json', | |
}, | |
method: 'POST', | |
} | |
) | |
.then(console.log); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment