Skip to content

Commit

Permalink
πŸ‘·β­• Add CI to build preview of the PR
Browse files Browse the repository at this point in the history
πŸ‘· Changed orb used to build the page

πŸ‘· removes executor - it may not be needed

πŸ‘· Using a πŸ§ͺπŸ‹

πŸ‘· Run πŸ§ͺ by itself without bundle (also without caching dependencies)

πŸ‘· Remove any Orb (they don't work as I think)

πŸ‘· Use an official πŸ§ͺπŸ‹ instead (it takes forever to install it otherwise)

πŸ‘· install everything using Gemfiles and caching it

πŸ‘· to build only for UCL πŸ›

πŸ‘·:pencil2: Fix small error! awk was only printing, not saving the changes

πŸ‘·πŸ› Fix a warning shown by Jekyll and GH API

Answer provided by this answer
github/pages-gem#399 (comment)

πŸ‘· Removed the "fix" that it doesn't work and the check for errors

πŸ‘·πŸ› Now I was getting an empty config! awk now allows also `inplace`!

πŸ‘·πŸ› who knows which version of awk they have there - using classic way

i.e. creating a tmp file in between
  • Loading branch information
dpshelio committed Jul 13, 2020
1 parent c056b1e commit b5c81ae
Showing 1 changed file with 84 additions and 0 deletions.
84 changes: 84 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Ruby CircleCI 2.1 configuration file
#
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
#
version: 2.1

jobs:
build:
docker:
# specify the version you desire here
- image: circleci/ruby:2.6.3-stretch-node
environment:
BUNDLE_PATH: ~/vendor/bundle

working_directory: ~/repo

steps:
- checkout
- run:
name: a merge PR
command: |
if [[ -n "${CIRCLE_PR_NUMBER}" ]]; then
git fetch origin +refs/pull/$CIRCLE_PR_NUMBER/merge:pr/$CIRCLE_PR_NUMBER/merge
git checkout -qf pr/$CIRCLE_PR_NUMBER/merge
fi
- run:
name: Which bundler/jekyll? create gemfile
command: |
bundle -v
printf "source 'https://rubygems.org'\nrequire 'json'\nrequire 'open-uri'\nversions = JSON.parse(open('https://pages.github.com/versions.json').read)\n\ngem 'github-pages', group: :jekyll_plugins\ngem 'html-proofer'" > Gemfile
cat Gemfile
# Download and cache dependencies
- restore_cache:
keys:
- rubygems-v1-latest

- run:
name: install dependencies
command: bundle check || bundle install --jobs=4 --retry=3

# - run:
# name: Use center settings
# command: |
# title='#Β Example: Name of your cluster, Name University'
# awk -v beg="${title}" -v num=8 '$0==beg{c=num} c&&c--{sub(/# /,"")} 1' _config.yml > tmp_config.yml
# mv -f tmp_config.yml _config.yml

- run:
name: Jekyll build
command: bundle exec jekyll build -d html 2> std.err

- run:
name: Check Jekyll build
command: cat std.err

- run:
name: Jekyll re-build for local
command: |
echo "url: https://${CIRCLE_BUILD_NUM}-30926520-gh.circle-artifacts.com" > circle.yml && \
bundle exec jekyll build -d html -b "/0/html" --config _config.yml,circle.yml && \
find ./html/ -type f -iname '*html' | xargs -I{} sed -i \
-e 's|href="\(\.\/.*\/\)"|href="\1index.html"|g' \
-e '/0\/html/ s|href="\(\/.*\/\)"|href="\1index.html"|g' {}
# Replace pages ending on `/` from our site to direct to index.html
- run:
name: "Built documentation is available at:"
command: DOCS_URL="${CIRCLE_BUILD_URL}/artifacts/${CIRCLE_NODE_INDEX}/html/index.html"; echo $DOCS_URL

- save_cache:
paths:
- ~/vendor/bundle
key: rubygems-v1-latest

# collect reports
- store_artifacts:
path: ~/repo/html
destination: html

notify:
webhooks:
- url: https://giles.cadair.dev/circleci

0 comments on commit b5c81ae

Please sign in to comment.