doctrine-website icon indicating copy to clipboard operation
doctrine-website copied to clipboard

Allow docs pull requests to trigger staging deploys

Open jwage opened this issue 6 years ago • 7 comments

Right now a docs PR won't work with staging deploys.

jwage avatar Apr 17 '18 05:04 jwage

Shouldn't we have separate deployments per PR ? Otherwise, the staging site always corresponds to the latest updated PR, which may not be the one you are interested in currently.

stof avatar Apr 18 '18 10:04 stof

Yes, eventually I would love to have it work that way. Just requires work.

jwage avatar Apr 18 '18 11:04 jwage

what is the hosting being used currently ?

stof avatar Apr 18 '18 12:04 stof

Github pages.

https://github.com/doctrine/doctrine-website-build-staging https://github.com/doctrine/doctrine-website-build-prod

This would have to change for at least staging or we have multiple deploys stored in the repo. Each one in a sub folder.

jwage avatar Apr 18 '18 14:04 jwage

I want to do it all with gh pages and without any custom hosting or vms for hooks. But I realize we are fairly limited in what we can do by having that restriction. The reason is we don't want to have to maintain any servers that require updates, access control, etc.

Right now we have a vm that receives web hooks, triggers the build and pushes to the gh pages build repository.

jwage avatar Apr 18 '18 14:04 jwage

so, how do you plan to trigger website build for updates in each projects ?

stof avatar Apr 24 '18 00:04 stof

@stof My current thought is to enhance the webhook script https://github.com/doctrine/doctrine-website/blob/master/hooks/deploy.php to store a JSON document for the last webhook received. I think it would just store the project and the sha. This script could be refactored and cleaned up in general too. It should just be using some classes in app/src instead of a standalone script.

Example JSON:

{
    "project":"mongodb-odm",
    "sha":"1234"
}

Then we enhance https://github.com/doctrine/doctrine-website/blob/master/app/src/Doctrine/Website/Docs/BuildDocs.php#L77 to allow you to sync git for a specific project & sha.

Then we can use that enhancement in https://github.com/doctrine/doctrine-website/blob/master/app/src/Doctrine/Website/Deployer.php#L80 to get the JSON document that we write from the github webhook and then dynamically build the commands to build the docs for that project and sha, rebuild the website and publish:

./doctrine build-docs --project={{ lastHook.project }} --sha={{ lastHook.sha }}
./doctrine build-website --env=staging --publish

Just for more context. On the server that receives the webhooks from github we have the following crons:

* * * * *  cd /data/doctrine-website-prod && ./doctrine deploy --env=prod --verbose >> /var/log/deployer-prod.log 2>&1
* * * * *  cd /data/doctrine-website-staging && ./doctrine deploy --env=staging --verbose >> /var/log/deployer-staging.log 2>&1

Every minute the deploy command is ran and it looks for the file written by the webhook script and checks if a deploy is required.

Even though it only supports deploying the last thing that was pushed, I think the frequency will be low enough initially for it to work fine. We could enhance staging later to have directories for each branch with some kind of cleanup process. Then you can go to https://staging.doctrine-project.org/branch-name and view your changes.

jwage avatar Apr 24 '18 01:04 jwage