lighthouse-ci
lighthouse-ci copied to clipboard
Automate deployment of LHCI
My team are currently looking to automate the deployment of LHCI, requiring no human interaction.
We're running into an issue where it seems that we can only generate an admin and build token via the wizard, which is interactive. Is there any way or commands that can be run in order to return those tokens without using the interactive wizard?
We're currently deploying the docker image, but that then prompts to use the wizard. We're hoping to move this to a 'cattle, not pets' design so we can easily tear down LHCI and bring it back up.
Thanks.
The wizard is just hitting the REST API for you so you could easily automate that by hitting it directly (either with the ApiClient
or your favorite request library in language of your choice).
https://github.com/GoogleChrome/lighthouse-ci/blob/51dc34aff470981aafa3b4df0c25a164e21073b5/packages/cli/src/wizard/wizard.js#L60-L78
Hi Patrick, We are looking to automate the run wizard steps for our project too. Can you please provide some pointers / documentation link on how to setup google APIs and call this particular one?
When I check the list of Google APIs here https://developers.google.com/apis-explorer/, I dont see any entry for createProject or lhci. Appreciate any help I can get.
Thanks, Naina
@nainaprabhu it's not a Google API, it's the API of your own Lighthouse CI server. The code to call this particular API is reproduced in the comment above.
I was having some trouble to figure out the API calls just by looking at the wizard file, and then I found these two files who definitely will guide your way: :smile:
- https://github.com/GoogleChrome/lighthouse-ci/blob/master/packages/server/src/api/routes/projects.js
- https://github.com/GoogleChrome/lighthouse-ci/blob/master/packages/utils/src/api-client.js
For everyone else who doesn't want to browse the whole API code here's a curl example to create a new project
curl --location --request POST 'http://localhost:9001/v1/projects' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "Test Project",
"externalUrl": "https://github.com/github/docs",
"baseBranch": "main"
#}'