Deployment

TravisCI

Project Site

You can easily deploy a cobalt site to gh-pages! To do this with travis is also very easy.

  1. Create your .travis.yml file:
sudo: false
before_script:
  - curl -LSfs https://japaric.github.io/trust/install.sh | sh -s -- --git cobalt-org/cobalt.rs --crate cobalt --force --target x86_64-unknown-linux-gnu
  - export PATH="$PATH:~/.cargo/bin"
script:
  - cobalt build

deploy:
  provider: pages
  skip_cleanup: true
  github_token: $GH_TOKEN
  local_dir: build
  target_branch: master
  on:
    branch: source
  • local_dir: update it according to your destination

  • target_branch: Update to reflect the branch that you configured as the source for Github Pages.

  • on: branch: Update to reflect the branch your source is kept in.

  1. Configure your GH_TOKEN

This is a limited access API token for Travis to commit to your page's github repo. You can create one here.

To add it to your .travis.yml file, you will need to use the travis cli tool. This will encrypt the token specifically to your repo and branch.

Example: travis encrypt GH_TOKEN=... --add env.global

Personal or Organization Site

The main difference with a personal site is that github only allows the master branch to serve the pages. Instead, you could keep your source in another branch, like source and have cobalt import your site into the master branch.

GitLab CI

You can also deploy a cobalt site to Gitlab Pages using GitLab CI. GitLab CI uses Docker, you can use nott/cobalt or any other image with cobalt in PATH.

An example of .gitlab-ci.yml:

image: nott/cobalt:latest

pages:
  script:
  - mkdir -p public
  - cobalt build -d public
  artifacts:
    paths:
    - public/
  only:
  - master

Other

To import your site to your gh-pages branch you can either pass a build --import flag when you build the site or after you have build the site with build you can run import. There are also some flags that can be found via import --help.