From a1414469215a4c375fe9d697a0a33a938d17dc7d Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 23 Nov 2018 22:12:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0cron=20CI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 11 ++++++++++- scripts/status.sh | 8 ++++++++ scripts/status/status.sh | 13 ++++++++----- 3 files changed, 26 insertions(+), 6 deletions(-) create mode 100755 scripts/status.sh diff --git a/.travis.yml b/.travis.yml index ab0090fa5a..99bc9b86a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,18 +1,27 @@ language: c +install: + - sudo apt-get install jq + - git clone --depth=1 -b gh-pages https://github.com/LCTT/TranslateProject/ build && rm -rf build/.git script: - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then sh ./scripts/check.sh; fi' - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then sh ./scripts/badge.sh; fi' + - 'if [ "$TRAVIS_EVENT_TYPE" = "cron" ]; then sh ./scripts/status.sh; fi' + branches: only: - master + # - status except: - gh-pages git: submodules: false + depth: false deploy: provider: pages skip_cleanup: true github_token: $GITHUB_TOKEN local_dir: build on: - branch: master + branch: + - master + # - status diff --git a/scripts/status.sh b/scripts/status.sh new file mode 100755 index 0000000000..f3cc4b8d82 --- /dev/null +++ b/scripts/status.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +# 重新生成badge +set -o errexit + +SCRIPTS_DIR=$(cd $(dirname "$0") && pwd) +BUILD_DIR=$(cd $SCRIPTS_DIR/.. && pwd)/build +mkdir -p ${BUILD_DIR}/status +${SCRIPTS_DIR}/status/status.sh > ${BUILD_DIR}/status/status.json diff --git a/scripts/status/status.sh b/scripts/status/status.sh index 9bb5aaf700..acb03bbf4e 100755 --- a/scripts/status/status.sh +++ b/scripts/status/status.sh @@ -13,12 +13,15 @@ function get_status_of() git log --date=short --pretty=format:"{\"file\":\"${file}\",\"time\":\"%ad\",\"user\":\"%an\"}" -n 1 "${file}" } -( -git grep -niE "translat|fanyi|翻译" sources/*.md |awk -F ":" '{if ($2<=3) print $1}' |xargs -I{} git log --date=short --pretty=format:"{\"filename\":\"{}\",\"time\":\"%ad\",\"user\":\"%an\"}" -n 1 "{}"|jq --slurp - +translating=$( git grep -niE "translat|fanyi|翻译" sources/*.md |awk -F ":" '{if ($2<=3) print $1}' |xargs -I{} git log --date=short --pretty=format:"{\"filename\":\"{}\",\"time\":\"%ad\",\"user\":\"%an\"}" -n 1 "{}") +unselected=$( find sources -name "2*.md"|sort|while read file;do if ! file-translating-p "${file}";then get_status_of "${file}" fi -done |jq --slurp -)|jq --slurp '{"translating":.[0],"unselected":.[1]}' +done +) +( +echo ${translating}|jq -s "." +echo ${unselected} |jq -s "." +)|jq -s '{"translating":.[0],"unselected":.[1]}'