Skip to content

Add deployment process #5

Description

@benjaminoakes

Goal: Ensure static content becomes available at https://rubysoftwareconservancy.github.io

Output goes to: https://github.com/rubysoftwareconservancy/rubysoftwareconservancy.github.io

Note: rubysoftwareconservancy.github.io may not have the same teams assigned as conservancy-site. It may be nice to have a deployment bot be the only user who can write to it.

Note: @benjaminoakes just created an empty repository. Other steps likely need to be taken.

From a previous spike:

  • Run Rails
  • Mirror the static content
  • Push that to GitHub Pages
# Usage: sh deploy.sh
# Purpose: Deploy static content to an unrelated public GitHub Pages repository
#
# Based on https://nanoc.app/doc/deploying/

# Configuration
local_server='http://localhost:3000'
mirror_directory='localhost:3000'
output_branch='gh-pages'
output_repository='git@github.com:rubysoftwareconservancy/rubysoftwareconservancy.github.io.git'
output_domain='rubysoftwareconservancy.github.io'

echo "Deployment started at $(date -Iseconds)"

if [ $(git branch --show-current) != 'main' ]; then
  >&2 echo 'Not on "main" branch'
  exit 1
else
  echo 'On "main" branch'
fi

if [ -z "$(git status --porcelain)" ]; then
  echo 'Working directory clean'
else
  >&2 echo 'Uncommitted changes'
  exit 2
fi

git push
rm -rf build
rm -f mirror.log

if curl --silent "$local_server/up"; then
  echo
  echo "Server up: $local_server/up"
else
  >&2 echo "Server down: $local_server/up"
  exit 3
fi

wget --output-file mirror.log --mirror "$local_server"

if grep --quiet ERROR mirror.log; then
  >&2 echo "Errors during mirroring.  See mirror.log for details."
  exit 4
fi

mv "$mirror_directory" build
cd build
git init .
git checkout --orphan "$output_branch"
echo "$output_domain" > CNAME
cat <<EOF > README.md
This is our deployed, static website.  To see it in action, please visit [$output_domain](https://$output_domain).
EOF
git add .
git commit -m 'Deploy'
git remote add deploy "$output_repository"
git push --force deploy "$output_branch"

cd -
echo "Deployment finished at $(date -Iseconds)"

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions