-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support multi-repo container building
- Loading branch information
1 parent
ded21df
commit 7c6c0bb
Showing
7 changed files
with
180 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Text files to normalise to LF line endings | ||
* text=auto | ||
# `man 5 .gitattributes` | ||
*.css text | ||
*.html text | ||
*.json text | ||
*.md text | ||
*.sh text | ||
*.xml text | ||
*.yml text | ||
|
||
# Binary files to not modify on check-in | ||
# Images | ||
*.ico binary | ||
*.jpg binary | ||
*.png binary | ||
# Fonts | ||
*.eot binary | ||
*.ttf binary | ||
*.woff binary | ||
*.woff2 binary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.asset-cache | ||
.sass-cache | ||
Gemfile.lock | ||
staging.96boards.org | ||
production.96boards.org | ||
merged_sources |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"diffEditor.ignoreTrimWhitespace": false, | ||
"files.eol": "\n", | ||
"files.insertFinalNewline": true, | ||
"files.trimFinalNewlines": true, | ||
"files.trimTrailingWhitespace": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
build-site.sh @pcolmer @morancj | ||
check-links.sh @pcolmer @morancj | ||
CODEOWNERS @pcolmer @morancj | ||
Gemfile @pcolmer @morancj | ||
manifest.json @pcolmer @morancj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#!/bin/bash | ||
|
||
check_multi_repo() { | ||
# A multi-repo site is defined by the presence of manifest.json. | ||
# | ||
# If that file exists, we look for the tags in the file, which | ||
# specifies the env var names that must be used to tell this | ||
# script where a local copy of that repo can be found. | ||
# | ||
# We then build up a list of mounts for Docker so that it can | ||
# access those repo copies. | ||
DOCKER_MOUNTS="" | ||
if [ ! -f "manifest.json" ]; then | ||
return | ||
fi | ||
# | ||
# Get the tags from the file. | ||
declare -a tags | ||
tags=($(grep \"tag\" manifest.json | cut -d':' -f2)) | ||
tag_count="${#tags[@]}" | ||
if [ "$tag_count" == 0 ]; then | ||
echo "Cannot find repo tags in manifest file." | ||
exit 1 | ||
fi | ||
# | ||
# Do any of them exist as variables that point to directories? | ||
for ((i=0; i < tag_count; i++)) | ||
do | ||
# Need to strip extraneous chars off the tag string | ||
tag="${tags[$i]}" | ||
# Strip the leading " and the trailing ", | ||
tag="${tag:1:-3}" | ||
# Does that tag name exist as a variable and have a value? | ||
tag_val="${!tag}" | ||
if [ "$tag_val" != "" ]; then | ||
# Does the value point to a directory? | ||
if [ -d "$tag_val" ]; then | ||
# Construct a Docker mount command | ||
DOCKER_MOUNTS="$DOCKER_MOUNTS -v $tag_val:/$tag" | ||
fi | ||
fi | ||
done | ||
} | ||
|
||
check_environment_variables() { | ||
if [ -z "$JEKYLLSITEBUILD" ]; then | ||
export JEKYLLSITEBUILD=latest | ||
fi | ||
if [ -z "$JEKYLL_ENV" ]; then | ||
export JEKYLL_ENV=staging | ||
fi | ||
if [ "$JEKYLL_ACTION" = "serve" ]; then | ||
PORTS="-p 4000:4000" | ||
else | ||
PORTS="" | ||
fi | ||
} | ||
|
||
check_interactive_running() { | ||
# Are we running interactively or via Bamboo? | ||
if [ -t 1 ]; then | ||
INTER="-i" | ||
else | ||
INTER="" | ||
fi | ||
} | ||
|
||
check_multi_repo | ||
check_environment_variables | ||
check_interactive_running | ||
|
||
docker run \ | ||
--cap-drop ALL \ | ||
--rm \ | ||
-t \ | ||
$INTER \ | ||
$PORTS \ | ||
-e JEKYLL_ACTION \ | ||
-e JEKYLL_ENV \ | ||
-v /etc/passwd:/etc/passwd:ro \ | ||
-v /etc/group:/etc/group:ro \ | ||
"$DOCKER_MOUNTS" \ | ||
-u "$(id -u)":"$(id -g)" \ | ||
-v "$(pwd)":/srv/source \ | ||
linaroits/jekyllsitebuild:"$JEKYLLSITEBUILD" \ | ||
build-site.sh "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
# | ||
# Calls the link checker container to run the tool against the current directory. | ||
# | ||
# The script is slightly more complicated that it could otherwise be because the | ||
# parameters to the tool can reference files and these will typically be in the | ||
# directory above the current directory, so we have to volume-map the parent | ||
# directory and tell the tool to check *this* directory. | ||
|
||
DIRNAME="$(basename "$(pwd)")" | ||
PARENT="$(dirname "$(readlink -f .)")" | ||
|
||
if [ -z "$LINKCHECK" ]; then | ||
LINKCHECK=latest | ||
fi | ||
|
||
# Make sure that the script is not in the current directory. The output from Jekyll | ||
# should be in a sub-directory of the git repository. | ||
SCRIPTDIR="$(dirname "$(readlink -f "$0")")" | ||
if [ "$SCRIPTDIR" == "$(pwd)" ]; then | ||
echo "Script is being run incorrectly. Go into the built site directory and" | ||
echo "then run:" | ||
echo | ||
echo "../check-links.sh" | ||
exit 1 | ||
fi | ||
|
||
docker run \ | ||
--cap-drop ALL \ | ||
--rm \ | ||
-t \ | ||
-v /etc/passwd:/etc/passwd:ro \ | ||
-v /etc/group:/etc/group:ro \ | ||
-u "$(id -u)":"$(id -g)" \ | ||
-v "$PARENT":/srv \ | ||
linaroits/linkcheck:"$LINKCHECK" \ | ||
-d "$DIRNAME" "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"site_dirs": [ | ||
"staging.96boards.org", | ||
"production.96boards.org" | ||
], | ||
"repos": [ | ||
{ | ||
"tag": "NSBREPO1", | ||
"url": "https://github.com/96boards/website.git", | ||
"dir": "/" | ||
}, | ||
{ | ||
"tag": "NSBREPO2", | ||
"url": "https://github.com/96boards/documentation.git", | ||
"dir": "/_documentation" | ||
} | ||
] | ||
} |