From 7f5be68c842cff31f3962ac2a0dda6696ee70724 Mon Sep 17 00:00:00 2001 From: Felix Wu Date: Fri, 5 Oct 2018 14:34:25 +0200 Subject: [PATCH 1/2] add travis --- .travis.yml | 16 ++++++++++++++++ .travis/forcepush.sh | 3 +++ .travis/push.sh | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 .travis.yml create mode 100644 .travis/forcepush.sh create mode 100644 .travis/push.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..0a3613911 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,16 @@ +language: node_js +node_js: + - node +install: + - npm install +script: + - npm run build +after_script: + - test $TRAVIS_EVENT_TYPE = cron + && echo -e "\e[95mDeploying to Repository" + && chmod +x .travis/push.sh + && ./.travis/push.sh + - chmod +x .travis/forcepush.sh && ./.travis/forcepush.sh +cache: + directories: + - node_modules \ No newline at end of file diff --git a/.travis/forcepush.sh b/.travis/forcepush.sh new file mode 100644 index 000000000..54f15f5a5 --- /dev/null +++ b/.travis/forcepush.sh @@ -0,0 +1,3 @@ +if [[ $TRAVIS_COMMIT_MESSAGE == *"--force-build"* ]]; + then echo -e "\e[95mFORCE-DEPLOY: Deploying to Repository" && chmod +x .travis/push.sh && ./.travis/push.sh; +fi diff --git a/.travis/push.sh b/.travis/push.sh new file mode 100644 index 000000000..55253cad0 --- /dev/null +++ b/.travis/push.sh @@ -0,0 +1,33 @@ +#!/bin/bash +setup_git() { + git config --global user.email "30secondsofcode@gmail.com" + git config --global user.name "30secondsofcode" +} + +commit_website_files() { + if [ $TRAVIS_EVENT_TYPE != "pull_request" ]; then + if [ $TRAVIS_BRANCH == "master" ]; then + echo "Committing to master branch..." + git checkout master + git add * + if [ $TRAVIS_EVENT_TYPE == "cron" ]; then + git commit --message "Travis build: $TRAVIS_BUILD_NUMBER [cron]" + else + git commit --message "Travis build: $TRAVIS_BUILD_NUMBER [FORCED]" + fi + fi + fi +} + +upload_files() { + if [ $TRAVIS_EVENT_TYPE != "pull_request" ]; then + if [ $TRAVIS_BRANCH == "master" ]; then + echo "Pushing to master branch..." + git push --force "https://${GH_TOKEN}@github.com/30-seconds/30-seconds-of-css.git" master > /dev/null 2>&1 + fi + fi +} + +setup_git +commit_website_files +upload_files From 14268ab27481b7bd467c9b64df58885d806d2707 Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Fri, 5 Oct 2018 23:34:39 +0300 Subject: [PATCH 2/2] Update push.sh --- .travis/push.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis/push.sh b/.travis/push.sh index 55253cad0..a6c1eb6b1 100644 --- a/.travis/push.sh +++ b/.travis/push.sh @@ -23,7 +23,7 @@ upload_files() { if [ $TRAVIS_EVENT_TYPE != "pull_request" ]; then if [ $TRAVIS_BRANCH == "master" ]; then echo "Pushing to master branch..." - git push --force "https://${GH_TOKEN}@github.com/30-seconds/30-seconds-of-css.git" master > /dev/null 2>&1 + git push --force --quiet "https://${GH_TOKEN}@github.com/30-seconds/30-seconds-of-css.git" master > /dev/null 2>&1 fi fi }