添加cron CI

This commit is contained in:
darksun 2018-11-23 22:12:56 +08:00
parent 23e9115850
commit a141446921
3 changed files with 26 additions and 6 deletions

View File

@ -1,18 +1,27 @@
language: c 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: script:
- 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then sh ./scripts/check.sh; fi' - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then sh ./scripts/check.sh; fi'
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then sh ./scripts/badge.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: branches:
only: only:
- master - master
# - status
except: except:
- gh-pages - gh-pages
git: git:
submodules: false submodules: false
depth: false
deploy: deploy:
provider: pages provider: pages
skip_cleanup: true skip_cleanup: true
github_token: $GITHUB_TOKEN github_token: $GITHUB_TOKEN
local_dir: build local_dir: build
on: on:
branch: master branch:
- master
# - status

8
scripts/status.sh Executable file
View File

@ -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

View File

@ -13,12 +13,15 @@ function get_status_of()
git log --date=short --pretty=format:"{\"file\":\"${file}\",\"time\":\"%ad\",\"user\":\"%an\"}" -n 1 "${file}" git log --date=short --pretty=format:"{\"file\":\"${file}\",\"time\":\"%ad\",\"user\":\"%an\"}" -n 1 "${file}"
} }
( 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 "{}")
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 unselected=$(
find sources -name "2*.md"|sort|while read file;do find sources -name "2*.md"|sort|while read file;do
if ! file-translating-p "${file}";then if ! file-translating-p "${file}";then
get_status_of "${file}" get_status_of "${file}"
fi fi
done |jq --slurp done
)|jq --slurp '{"translating":.[0],"unselected":.[1]}' )
(
echo ${translating}|jq -s "."
echo ${unselected} |jq -s "."
)|jq -s '{"translating":.[0],"unselected":.[1]}'