diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b034dc5b2ddc7c670355024577b0ac4865eb130f..18ce9eeec23c8e3b0f0126f05c59c8e05a0fccd2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -23,8 +23,5 @@ build-list: - git config --global user.email "$GITLAB_USER_EMAIL" script: - - node build_list.js - - node validate_json.js - - git add list/e_trackers.json - - git commit -m "Auto update trackers list" - - git push origin HEAD:main + - doupdate.sh + diff --git a/build_list.js b/build_list.js index 6b986608777fbb2373a6f4f633f8835f73bb4a08..aa2dca26cfd8c7e95f0356b8b02c5e8e35bc5ffa 100644 --- a/build_list.js +++ b/build_list.js @@ -8,6 +8,8 @@ const https = require('https') const fs = require('fs') const url = require('url') +const EXIT_CODE_NO_CHANGES = 5 + function fetch(url) { return new Promise((resolve, reject) => { https.get(url, (response) => { @@ -56,6 +58,7 @@ fetch(adawayUri) }) .then(toto => { if (listHasNoChanges()) { + process.exitCode = EXIT_CODE_NO_CHANGES throw "No changes in trackers, abort updating." } }) @@ -69,8 +72,10 @@ fetch(adawayUri) console.log("DONE") }) .catch(err => { + if (process.exitCode === undefined) { + process.exitCode = 1 + } console.log(err) - process.exit(1) }) diff --git a/doupdate.sh b/doupdate.sh new file mode 100755 index 0000000000000000000000000000000000000000..213f8ca66c68a134487a8beaaf40e32f3ca60c51 --- /dev/null +++ b/doupdate.sh @@ -0,0 +1,22 @@ +#!/bin/sh + + +node build_list.js + +RETVAL=$? + +case "$RETVAL" in + "0") + node validate_json.js + git add list/e_trackers.json + git commit -m "Auto update trackers list" + git push origin HEAD:main + ;; + "5") + RETVAL=0 + ;; + *) + ;; +esac + +exit $RETVAL