11#! /usr/bin/env bash
22set -euo pipefail
33
4- for cmd in curl git sed ; do
4+ for cmd in git tr ; do
55 if ! command -v " ${cmd} " > /dev/null 2>&1 ; then
66 echo " ${cmd} is required for .devcontainer/post-create.sh"
77 exit 1
4545echo " Initializing/updating git submodules"
4646git submodule update --init --recursive
4747
48- versions_json=" $( curl -fsSL https://pages.github.com/versions.json) " || {
49- echo " Failed to fetch https://pages.github.com/versions.json"
48+ ruby_version_file=" .ruby-version"
49+ if [[ ! -f " ${ruby_version_file} " ]]; then
50+ echo " Could not find ${ruby_version_file} "
5051 exit 1
51- }
52-
53- pages_ruby_version=" $(
54- printf ' %s' " ${versions_json} " |
55- sed -n ' s/.*"ruby"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' |
56- head -n 1
57- ) "
52+ fi
5853
59- echo " GitHub Pages Ruby version: ${pages_ruby_version} "
54+ repo_ruby_version=" $( tr -d ' [:space:]' < " ${ruby_version_file} " ) "
55+ echo " Repository Ruby version: ${repo_ruby_version} "
6056
61- if [[ -z " ${pages_ruby_version } " ]]; then
62- echo " Could not determine Ruby version from https://pages.github.com/versions.json "
57+ if [[ -z " ${repo_ruby_version } " ]]; then
58+ echo " Could not determine Ruby version from ${ruby_version_file} "
6359 exit 1
6460fi
6561
7571export PATH=" $HOME /.rbenv/bin:$HOME /.rbenv/shims:$PATH "
7672eval " $( rbenv init - bash) "
7773
78- rbenv install -s " ${pages_ruby_version } "
79- rbenv global " ${pages_ruby_version } "
74+ rbenv install -s " ${repo_ruby_version } "
75+ rbenv global " ${repo_ruby_version } "
8076rbenv rehash
8177
8278for profile in " $HOME /.bashrc" " $HOME /.zshrc" ; do
@@ -94,4 +90,4 @@ gem install bundler --no-document
9490rbenv rehash
9591mkdir -p " $HOME /.local/bin"
9692ln -sf " $HOME /.rbenv/shims/bundle" " $HOME /.local/bin/bundle"
97- bundle install
93+ bundle install
0 commit comments