Skip to content

Deploy steps

Christoph Deil edited this page Sep 15, 2017 · 7 revisions

Deploying to GitHub Pages

We set up our project so that all scripts and raw code are located in the master branch, while only our bundled app is located in the gh-pages branch. We clean the version history of the gh-pages branch on each deploy.

The basic idea is that to deploy you have cloned the gamma-sky repo twice:

  • In a directory gamma-sky where you are in the master branch and generate the files and app
  • In a directory gamma-sky-deploy where you are in the gh-pages branch and commit and deploy the app

These steps that must be taken to deploy any changes in the code to GitHub Pages.

Prepare data

To refresh the data directory, in case any changes have been made, call in the root directory:

python make.py fetch all
python make.py all

Update website version

With each deploy, we should change our website version so we can begin to build a version history. For now, we are editing the version and last_modified keys in src/data/app_info.json by hand. In the future, we can implement a script to set new version numbers.

Build step

This step bundles files in a dist/ folder. From the master branch, call:

ng build --target=production --aot=false --base-href ./

Create deploy repo

If you're deploying for the first time:

cd ..
git clone [email protected]:gammapy/gamma-sky.git gamma-sky-deploy
cd gamma-sky-deploy/

(Alternatively, clone into the URL version of the project: https://github.com/gammapy/gamma-sky.git)

Otherwise:

cd ..
cd gamma-sky-deploy/

Clean gh-pages branch

The following will wipe the contents and clear the git history in the gh-pages branch:

git checkout gh-pages
git symbolic-ref HEAD refs/heads/gh-pages
rm .git/index
git clean -fdx

Copy over contents of dist/ folder and commit

cp -r ../gamma-sky/dist/* .
git add .
git commit -m <commit message>

Testing before deploy with http.server

python -m http.server

Finally, push to GitHub

git push -f origin gh-pages

Testing after deploy

As a final check, go check the webpage online to see if it is working properly!

It's here:

Usually it takes a minute to update, sometimes a few minutes.