From f31dc7d092818545278dd837ad92d808dd768952 Mon Sep 17 00:00:00 2001 From: CRIMX Date: Thu, 4 Oct 2018 19:29:18 +0800 Subject: [PATCH] Add CI for downloading emojis --- .travis.yml | 7 +++++++ push.sh | 19 +++++++++++++++++++ update-emojis.js | 3 ++- 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 .travis.yml create mode 100644 push.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..0b39207 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: node_js +node_js: + - "8" +script: + - node update-emojis.js +after_success: + - bash push.sh diff --git a/push.sh b/push.sh new file mode 100644 index 0000000..0a0de22 --- /dev/null +++ b/push.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +setup_git() { + git config --global user.email "travis@travis-ci.org" + git config --global user.name "Travis CI" +} + +commit_git() { + git add --all + git commit -am "[ci skip] Travis build: $TRAVIS_BUILD_NUMBER" +} + +push_git() { + git push https://${GH_TOKEN}@github.com/crimx/hexo-filter-github-emojis.git HEAD:master +} + +setup_git +commit_git +push_git diff --git a/update-emojis.js b/update-emojis.js index 62cf63c..cbee39d 100644 --- a/update-emojis.js +++ b/update-emojis.js @@ -16,7 +16,7 @@ request({ if (error || !_.isObject(json)) { console.error('Failded to download Github emojis.') console.log(error, response, json) - return + process.exit(1) } const latestEmojis = Object.keys(json).reduce((emojis, name) => { @@ -39,6 +39,7 @@ request({ function (err) { if (err) { console.warn(err) + process.exit(1) } else { console.log(`Update ${Object.keys(emojis).length} emojis`) }