Table of contents

Deploy

By default the static website is built in the _site directory and can be deployed as is.

Below are some recipes to automate build and/or deployment of a satic site.

Build and deploy with Netlify

netlify.toml:

[build]
  command = "chmod +x netlify.sh && bash netlify.sh"
  publish = "_site"
  environment = { PHP_VERSION = "7.2" }

[context.deploy-preview]
  command = "chmod +x netlify.sh && bash netlify.sh $DEPLOY_PRIME_URL"

[context.branch-deploy]
  command = "chmod +x netlify.sh && bash netlify.sh $DEPLOY_PRIME_URL"

netlify.sh:

echo "Downloading Cecil"
curl -sSOL https://cecil.app/cecil.phar
php cecil.phar --version

echo "Started Cecil build"
if [ -z "$1" ]; then php cecil.phar build --baseurl=$URL --quiet; else echo "URL: $1" && php cecil.phar build --baseurl=$1 --drafts --quiet; fi
echo "Finished Cecil build"

exit 0

Official documentation

Build and deploy with Travis CI

.travis.yml:

language: php
php:
  - 7.2
sudo: false
branches:
  only:
    - master
# Download Cecil
install:
  - curl -SOL https://cecil.app/cecil.phar
# Display Cecil version
before_script:
  - php cecil.phar -v
# Run Cecil build
script:
  - php cecil.phar build -q
# Deploy to GitHub Pages
deploy:
  provider: pages
  skip_cleanup: true
  github_token: $GH_TOKEN
  local_dir: _site
  on:
    branch: master

Official documentation

Build with LambCI

.lambci.json:

{
  "cmd": "chmod +x ./scripts/lambci.sh && ./scripts/lambci.sh"
}

scripts/lambci.sh:

#!/bin/bash -e

. ~/init/php 7.1.24

echo "Downloading Cecil"
curl -SOL https://cecil.app/cecil.phar
php cecil.phar --version

echo "Started themes installation"
composer install
echo "Finished themes installation"

echo "Started Cecil build"
php cecil.phar build --verbose

# build success? can deploy?
if [ $? = 0 ]
then
  echo "Finished Cecil build"
  bash scripts/deploy.sh
else
  return 1
fi

Official documentation

Deploy to GitHub Pages

scripts/deploy.sh:

#!/bin/bash -e

USER_NAME="Build Bot"
USER_EMAIL="build@narno.com"
REPOSITORY="Narno/narno.com"
SOURCE_BRANCH="master"
TARGET_BRANCH="gh-pages"
SITE_DIR="_site"

echo "Started deploy to GitHub Pages"

cp -R $SITE_DIR $HOME/$SITE_DIR
cd $HOME
git config --global user.name "$USER_NAME"
git config --global user.email "$USER_EMAIL"
git clone --quiet --branch=$TARGET_BRANCH https://${GITHUB_TOKEN}@github.com/${REPOSITORY}.git $TARGET_BRANCH > /dev/null
cp -R gh-pages/.git $HOME/.git
rm -rf gh-pages/*
cp -R $HOME/.git gh-pages/.git
cd gh-pages
cp -Rf $HOME/$SITE_DIR/* .
git add -Af .
git commit -m "$USER_NAME pushed to $TARGET_BRANCH"
git push -fq origin $TARGET_BRANCH > /dev/null

echo "Finished deploy to GitHub Pages"

exit 0

Official documentation

Suggest a modification

Commands Library