lighthouse-ci icon indicating copy to clipboard operation
lighthouse-ci copied to clipboard

Automate deployment of LHCI

Open JoeAshworthMSM opened this issue 4 years ago • 5 comments

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.

JoeAshworthMSM avatar Oct 27 '20 10:10 JoeAshworthMSM

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

patrickhulce avatar Oct 27 '20 15:10 patrickhulce

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 avatar Nov 26 '20 07:11 nainaprabhu

@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.

patrickhulce avatar Nov 30 '20 15:11 patrickhulce

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

fsmaia avatar Dec 08 '20 17:12 fsmaia

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"
 #}'

a-stein avatar Dec 01 '22 14:12 a-stein