Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

showcase & api docs: publish to github pages #282

Closed
26 of 28 tasks
dsebastien opened this issue Mar 27, 2018 · 10 comments · Fixed by #445
Closed
26 of 28 tasks

showcase & api docs: publish to github pages #282

dsebastien opened this issue Mar 27, 2018 · 10 comments · Fixed by #445

Comments

@dsebastien
Copy link
Contributor

dsebastien commented Mar 27, 2018

Build & deploy the showcase and api docs to github pages when creating releases

Preparation:

  • enable gh-pages for stark
  • create a gh-pages branch
  • clean the gh-pages branch (should start empty)
  • create the api-docs and showcase folders in that branch
  • create the api-docs\stark-core\latest and api-docs\stark-ui\latest folders
  • create a latest folder in showcase
  • create the showcase app based on starter: showcase: create package #353
  • adapt the .travis.yml to also generate the prod build of the showcase
    • added a new script: npm run build:showcase

Then create a script (gh-deploy.sh) executed as part of the Travis CI build that will...

First perform checks:

  • checks if the build occurs on the main Stark repository and not on a fork); IF NOT then it exits (0)
  • checks if the build occurs on the correct node version (we don't want to publish docs for each version of node we test against); IF NOT then it exits (0)
  • checks if the build occurs for a PR; IF SO, then it exits (0)
  • checks if the build is for a release; IF NOT then it exits (0)
  • checks that the necessary decryption keys for the SSH private key are available as environment variables (necessary to be able to push our changes to GitHub!)

Then generate the API docs

  • npm run docs:all

The prepare the docs for upload to the github-pages branch:

  • identifies the version the build is executed for
  • ensures that the identified version matches the version in stark/showcase/package.json; IF NOT then if fails (-1) because it means that the showcase hasn't been updated for the release
  • creates the showcase/<version> folder
  • copies the showcase build output to showcase/<version>
  • copies the showcase build output to showcase/latest

In addition, for each stark module:

  • creates the api-docs/<stark-module>/<version> folder
  • generates the api-docs for the module and copies the output to api-docs/<stark-module>/<version>
  • copies the api-docs to api-docs/<stark-module>/latest

Finally:

  • adds, commits and pushes the changes to the gh-pages branch to github
  • question: how will we mock the back-end with GitHub pages?

Docs:

  • document the key generation / configuration
    • see last comments

Bonus

  • create a DNS CNAME record to nbb.be (e.g., opensource.nbb.be) and make it point to https://nationalbankbelgium.github.io
    • opensource.nbb.be created
  • define the custom domain on Stark's repository
  • enable HTTPS for the custom domain (need to wait for the certificate to be ready)
  • create a homepage and add a link to Stark docs: opensource.nbb.be/stark/api-docs/showcase/latest`

Refs:

@dsebastien
Copy link
Contributor Author

Blocked by #148

@dsebastien dsebastien changed the title starter: poc to deploy to gh pages demo/starter: poc to deploy to gh pages Apr 24, 2018
@dsebastien dsebastien modified the milestones: should, must Apr 24, 2018
@dsebastien dsebastien added the P2 label Apr 24, 2018
@dsebastien dsebastien changed the title demo/starter: poc to deploy to gh pages deploy showcase and api docs to github pages May 3, 2018
@dsebastien dsebastien modified the milestones: must, 10.0.0-alpha.3 May 3, 2018
@dsebastien dsebastien self-assigned this May 3, 2018
@dsebastien
Copy link
Contributor Author

Alternative option for deployment to gh-pages for simpler projects: https://docs.travis-ci.com/user/deployment/pages/

@dsebastien
Copy link
Contributor Author

@christophercr just thought about this, but so far we didn't think about the distinction between stark-core and stark-ui api docs.. I guess each needs its own sub-folder under api-docs?

So the structure would be like:

| api-docs
|-- stark-core
|---- <version>
|-- stark-ui
|---- <version>

@dsebastien
Copy link
Contributor Author

Docs publication currently blocked by #127

@dsebastien
Copy link
Contributor Author

Showcase publication currently blocked by #353

@christophercr
Copy link
Collaborator

@dsebastien indeed, we overlooked that. I agree with the folder structure you propose ;)

@dsebastien
Copy link
Contributor Author

Okay, proposal adapted!

@dsebastien dsebastien changed the title deploy showcase and api docs to github pages showcase & api docs: publish to github pages May 8, 2018
@dsebastien
Copy link
Contributor Author

dsebastien commented Jun 5, 2018

I'll adapt the proposal to match our last discussion:

  • we'll generate a repo-specific SSH keypair for Stark: ssh-keygen -t rsa -b 4096 -C "..." and save it as stark-ssh
  • we'll associate the public key with Stark: this is called a deploy key on github: https://developer.github.com/v3/guides/managing-deploy-keys/ (Settings > Deploy Keys > Add)
  • we'll encrypt the private key with travis cli: travis encrypt-file mysuperprivatekey. Travis will store the necessary decryption material inside the repo config in Travis (protected vars)
  • we'll store the encrypted private key in the sources
  • we'll decrypt the key in the CI, paying attention not to leak it out :p
  • we'll use it to clone/push using ssh

Travis CLI:

  • Install Ruby to get the gem cli
  • Install Travis CLI with gem install travis
  • Login to Travis using GH credentials: travis login --org --github-token foo
    • Successfully logged in as ...

Encrypting the private key: travis encrypt-file ./stark-ssh -r NationalBankBelgium/stark

  • generates stark-ssh.enc
  • provides command to use in the scripts to decrypt the stark-ssh.enc file: openssl aes-256-cbc -K $encrypted_e546efaa49e5_key -iv $encrypted_e546efaa49e5_iv -in stark-ssh.enc -out ./stark-ssh -d
    • Travis will provide us with those variables

@dsebastien
Copy link
Contributor Author

GH repos are limited to ~1GB and stark-core's API docs alone is ~25MB, so our initial idea of also keeping API docs for nightly builds will not hold for long.

I'll only allow releases to get their published docs.

dsebastien added a commit to dsebastien/stark that referenced this issue Jun 5, 2018
dsebastien added a commit to dsebastien/stark that referenced this issue Jun 5, 2018
dsebastien added a commit to dsebastien/stark that referenced this issue Jun 5, 2018
@christophercr
Copy link
Collaborator

christophercr commented Jun 15, 2018

One issue to keep in mind while generating the encrypted key on Windows :s travis-ci/travis-ci#4746

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment