未验证 提交 656fea52 编写于 作者: B beyondgfw

Make deploy.sh work in more environments, rename it to build.sh

build.sh should take the place of generate-local.sh.
上级 abc4a51e
......@@ -2,8 +2,8 @@ language: node_js
node_js: node
branches:
only:
- hosts-source
except:
- master
script:
- ./deploy.sh
- ./build.sh
......@@ -4,12 +4,29 @@ set -e
function echogr {
echo -e \\033[32m$@\\033[0m
}
function echoye {
echo -e \\033[33m$@\\033[0m
}
echogr Generating hosts files.
mkdir output
node src/generate.js "$PWD/data" $(git show -s --format=%cd --date=short) "$PWD/output"
mkdir -p output
if command -v git > /dev/null; then
DATE=$(git show -s --format=%cd --date=short)
else
echoye Git not found, using current date for the \"Last updated\" field.
DATE=$(date +%Y-%m-%d)
fi
node src/generate.js "$PWD/data" $DATE "$PWD/output"
if [ "$TRAVIS" != "true" ]; then
echoye Not running on Travis CI, deployment skipped.
elif [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
echoye Building for a pull request, deployment skipped.
elif [ "$TRAVIS_BRANCH" != "hosts-source" ]; then
echoye Bulding for a branch other than \"hosts-source\", deployment skipped.
else
echogr Starting deployment.
if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
echogr Importing SSH key.
base64 -d <<< $SSH_KEY > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
......@@ -52,6 +69,4 @@ if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
else
echogr No changes detected, deployment skipped.
fi
else
echogr Running in an untrusted environment, deployment skipped.
fi
#!/bin/bash
set -e
if [ -e output ]; then
rm -rf output
fi
mkdir output
node src/generate.js "$PWD/data" $(git show -s --format=%cd --date=short) "$PWD/output"
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册