From f130ce332742a4e9dad8c6033d3b6faf05c8173f Mon Sep 17 00:00:00 2001 From: Tom Dooner Date: Sun, 29 May 2016 13:48:02 -0700 Subject: [PATCH 1/5] Add first attempt at travis.yml build script --- renderAndPush.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 renderAndPush.sh diff --git a/renderAndPush.sh b/renderAndPush.sh new file mode 100755 index 0000000..e87e316 --- /dev/null +++ b/renderAndPush.sh @@ -0,0 +1,20 @@ +#!/bin/bash +set -euo pipefail + +if ! git diff --quiet; then + echo "You have uncommitted changes that will be blown away!" + exit 1 +fi + +if ! git diff --cached --quiet; then + echo "You have uncommitted changes that will be blown away!" + exit 1 +fi + +npm run render +git branch -D gh-pages 2>/dev/null || true +git checkout -b gh-pages +mv build/ocd-division . +git add ocd-division +git commit --quiet -m "Generated build at $(date)" +git push origin gh-pages From 0d3d8fdfb7268f416fbb690d7d332805d0e1c9a7 Mon Sep 17 00:00:00 2001 From: Tom Dooner Date: Sun, 29 May 2016 13:56:35 -0700 Subject: [PATCH 2/5] Update deploy script to handle GITHUB_AUTH_TOKEN secret --- renderAndPush.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/renderAndPush.sh b/renderAndPush.sh index e87e316..1c482ea 100755 --- a/renderAndPush.sh +++ b/renderAndPush.sh @@ -11,10 +11,18 @@ if ! git diff --cached --quiet; then exit 1 fi +if [ ! -d .git ]; then + git init + git config user.name "Travis-CI Deploy Bot" + git config user.email "tomdooner@gmail.com" +fi + +# render everything npm run render + git branch -D gh-pages 2>/dev/null || true git checkout -b gh-pages mv build/ocd-division . git add ocd-division git commit --quiet -m "Generated build at $(date)" -git push origin gh-pages +git push --force "https://x-api-token:${GITHUB_AUTH_TOKEN}@github.com/tdooner/brigade-maps.git" gh-pages From c16d009f7853daa90e3d53fc5d5352e580dac16c Mon Sep 17 00:00:00 2001 From: Tom Dooner Date: Sun, 29 May 2016 13:59:21 -0700 Subject: [PATCH 3/5] Commit the .travis.yml --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..46352ea --- /dev/null +++ b/.travis.yml @@ -0,0 +1,4 @@ +language: node_js +node_js: + - "5" +script: ./renderAndPush.sh From 537a1b6f4c45e8dc549ada796c1fd7abcc6ad0e6 Mon Sep 17 00:00:00 2001 From: Tom Dooner Date: Sun, 29 May 2016 14:38:55 -0700 Subject: [PATCH 4/5] Double-escape backslashes in unzip arguments Unzip needs to receive a glob instead of it being expanded by the shell, or else unzip will try to extract the 2nd-last zip files from the first one. --- Jakefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Jakefile b/Jakefile index 01a0b5d..f315030 100644 --- a/Jakefile +++ b/Jakefile @@ -90,7 +90,7 @@ file('shapefiles/sldl', { async: true }, () => { 'bash -c "' + 'cd ' + tempdir + ' && ' + 'wget -r -nH --cut-dirs=4 -nc ftp://ftp2.census.gov/geo/tiger/TIGER2014/SLDL && ' + - 'unzip ./\*.zip && ' + + 'unzip ./\\*.zip && ' + 'rm ./*.zip"', 'mv ' + tempdir + ' shapefiles/sldl' ], { printStdout: true, printStderr: true }, complete); @@ -104,7 +104,7 @@ file('shapefiles/sldl', { async: true }, () => { 'bash -c "' + 'cd ' + tempdir + ' && ' + 'wget -r -nH --cut-dirs=4 -nc ftp://ftp2.census.gov/geo/tiger/TIGER2014/SLDL && ' + - 'unzip ./\*.zip && ' + + 'unzip ./\\*.zip && ' + 'rm ./*.zip"', 'mv ' + tempdir + ' shapefiles/sldl' ], { printStdout: true, printStderr: true }, complete); @@ -118,7 +118,7 @@ file('shapefiles/sldu', { async: true }, () => { 'bash -c "' + 'cd ' + tempdir + ' && ' + 'wget -r -nH --cut-dirs=4 -nc ftp://ftp2.census.gov/geo/tiger/TIGER2014/SLDU && ' + - 'unzip ./\*.zip && ' + + 'unzip ./\\*.zip && ' + 'rm ./*.zip"', 'mv ' + tempdir + ' shapefiles/sldl' ], { printStdout: true, printStderr: true }, complete); @@ -132,7 +132,7 @@ file('shapefiles/place', { async: true }, () => { 'bash -c "' + 'cd ' + tempdir + ' && ' + 'wget -r -nH --cut-dirs=4 -nc ftp://ftp2.census.gov/geo/tiger/TIGER2014/PLACE && ' + - 'unzip ./\*.zip && ' + + 'unzip ./\\*.zip && ' + 'rm ./*.zip"', 'mv ' + tempdir + ' shapefiles/place' ], { printStdout: true, printStderr: true }, complete); @@ -146,7 +146,7 @@ file('shapefiles/county', { async: true }, () => { 'bash -c "' + 'cd ' + tempdir + ' && ' + 'wget -r -nH --cut-dirs=4 -nc ftp://ftp2.census.gov/geo/tiger/TIGER2014/COUNTY && ' + - 'unzip ./\*.zip && ' + + 'unzip ./\\*.zip && ' + 'rm ./*.zip"', 'mv ' + tempdir + ' shapefiles/county' ], { printStdout: true, printStderr: true }, complete); @@ -163,7 +163,7 @@ file('shapefiles/cousub', { async: true }, () => { 'bash -c "' + 'cd ' + tempdir + ' && ' + 'wget -r -nH --cut-dirs=4 -nc ftp://ftp2.census.gov/geo/tiger/TIGER2014/COUSUB && ' + - 'unzip ./\*.zip && ' + + 'unzip ./\\*.zip && ' + 'rm ./*.zip"', 'mv ' + tempdir + ' shapefiles/cousub' ], { printStdout: true, printStderr: true }, complete); From 54ad10afe55d4832649254aaa18445c067b2a02a Mon Sep 17 00:00:00 2001 From: Tom Dooner Date: Sun, 29 May 2016 14:40:07 -0700 Subject: [PATCH 5/5] Cache shapefiles directory for SPEED --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 46352ea..85e3bff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,3 +2,6 @@ language: node_js node_js: - "5" script: ./renderAndPush.sh +cache: + directories: + - shapefiles