mirror of
https://github.com/tldr-pages/tldr.git
synced 2025-04-29 23:24:55 +02:00
Travis: separate building from deployment.
- Added `-q` to the zip command to create the archive since Travis was having trouble handling its very long output (thus making the build fail). - Moved the actual building of the index and the archive from deploy.sh to a new build.sh script. - Added a `script` step in .travis.yml to run build.sh after npm test. - Specified a clone depth of 1 in .travis.yml to make things faster since we don't need to do any git operation during the build.
This commit is contained in:
parent
b7442d3696
commit
a188a3a8ca
3 changed files with 40 additions and 15 deletions
|
@ -4,6 +4,13 @@ language: node_js
|
||||||
node_js: stable
|
node_js: stable
|
||||||
cache: false
|
cache: false
|
||||||
|
|
||||||
|
git:
|
||||||
|
depth: 1
|
||||||
|
|
||||||
|
script:
|
||||||
|
- npm test
|
||||||
|
- bash scripts/build.sh
|
||||||
|
|
||||||
after_failure:
|
after_failure:
|
||||||
- python scripts/send_to_bot.py < test_result
|
- python scripts/send_to_bot.py < test_result
|
||||||
|
|
||||||
|
|
32
scripts/build.sh
Normal file
32
scripts/build.sh
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# This script is executed by Travis CI for every successful push (on any branch, PR or not).
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
function initialize {
|
||||||
|
if [ -z "$TLDRHOME" ]; then
|
||||||
|
export TLDRHOME=${TRAVIS_BUILD_DIR:-$(pwd)}
|
||||||
|
fi
|
||||||
|
|
||||||
|
export TLDR_ARCHIVE="tldr.zip"
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_index {
|
||||||
|
npm run build-index
|
||||||
|
echo "Pages index succesfully built."
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_archive {
|
||||||
|
rm -f "$TLDR_ARCHIVE"
|
||||||
|
cd "$TLDRHOME/"
|
||||||
|
zip -q -r "$TLDR_ARCHIVE" pages* LICENSE.md index.json
|
||||||
|
echo "Pages archive succesfully built."
|
||||||
|
}
|
||||||
|
|
||||||
|
###################################
|
||||||
|
# MAIN
|
||||||
|
###################################
|
||||||
|
|
||||||
|
initialize
|
||||||
|
build_index
|
||||||
|
build_archive
|
|
@ -7,9 +7,9 @@ function initialize {
|
||||||
if [ -z "$TLDRHOME" ]; then
|
if [ -z "$TLDRHOME" ]; then
|
||||||
export TLDRHOME=${TRAVIS_BUILD_DIR:-$(pwd)}
|
export TLDRHOME=${TRAVIS_BUILD_DIR:-$(pwd)}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export TLDR_ARCHIVE="tldr.zip"
|
export TLDR_ARCHIVE="tldr.zip"
|
||||||
export SITE_HOME="$HOME/site"
|
export SITE_HOME="$HOME/site"
|
||||||
export SITE_URL="github.com/tldr-pages/tldr-pages.github.io"
|
|
||||||
export SITE_REPO_SLUG="tldr-pages/tldr-pages.github.io"
|
export SITE_REPO_SLUG="tldr-pages/tldr-pages.github.io"
|
||||||
|
|
||||||
# Configure git.
|
# Configure git.
|
||||||
|
@ -25,18 +25,6 @@ function initialize {
|
||||||
ssh-add id_ed25519
|
ssh-add id_ed25519
|
||||||
}
|
}
|
||||||
|
|
||||||
function rebuild_index {
|
|
||||||
npm run build-index
|
|
||||||
echo "Rebuilding index done."
|
|
||||||
}
|
|
||||||
|
|
||||||
function build_archive {
|
|
||||||
rm -f "$TLDR_ARCHIVE"
|
|
||||||
cd "$TLDRHOME/"
|
|
||||||
zip -r "$TLDR_ARCHIVE" pages*/ LICENSE.md index.json
|
|
||||||
echo "Pages archive created."
|
|
||||||
}
|
|
||||||
|
|
||||||
function upload_assets {
|
function upload_assets {
|
||||||
git clone --quiet --depth 1 git@github.com:${SITE_REPO_SLUG}.git "$SITE_HOME"
|
git clone --quiet --depth 1 git@github.com:${SITE_REPO_SLUG}.git "$SITE_HOME"
|
||||||
mv -f "$TLDR_ARCHIVE" "$SITE_HOME/assets/"
|
mv -f "$TLDR_ARCHIVE" "$SITE_HOME/assets/"
|
||||||
|
@ -55,6 +43,4 @@ function upload_assets {
|
||||||
###################################
|
###################################
|
||||||
|
|
||||||
initialize
|
initialize
|
||||||
rebuild_index
|
|
||||||
build_archive
|
|
||||||
upload_assets
|
upload_assets
|
||||||
|
|
Loading…
Add table
Reference in a new issue