aboutsummaryrefslogtreecommitdiff
path: root/simepleci.sh
diff options
context:
space:
mode:
Diffstat (limited to 'simepleci.sh')
-rwxr-xr-xsimepleci.sh71
1 files changed, 0 insertions, 71 deletions
diff --git a/simepleci.sh b/simepleci.sh
deleted file mode 100755
index 43aef34..0000000
--- a/simepleci.sh
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/bin/bash
-
-SCRIPT_DIR="$(readlink -f $(dirname ${BASH_SOURCE[0]}))"
-
-JOB_DIR="${SCRIPT_DIR}/jobs"
-WORKSPACE_DIR="${SCRIPT_DIR}/workspaces"
-
-check_for_remote_changes() {
- local DIR=$1
- local BRANCH=$2
-
- pushd "${DIR}" > /dev/null || { echo "Directory ${DIR} not found!"; return 1; }
-
- # Fetch the latest changes from the remote
- git fetch
-
- # Get the local and remote commit hashes for the branch
- LOCAL=$(git rev-parse "${BRANCH}")
- REMOTE=$(git rev-parse "origin/${BRANCH}")
-
- # Check if local and remote are different
- if [ "${LOCAL}" != "${REMOTE}" ]; then
- echo $(date +"%Y-%m-%d %H:%M:%S") "Remote changes detected in ${DIR}"
- popd > /dev/null
- return 0
- else
- echo $(date +"%Y-%m-%d %H:%M:%S") "No remote changes in ${DIR}"
- popd > /dev/null
- return 1
- fi
-}
-
-trigger() {
- REPO=""
- BRANCH="live"
- COMMAND="make publish"
- source "${1}"
- DIR="$(echo ${REPO##*/} | sed -e 's/\.git$//')"
- FORCE=${2}
-
-# echo REPO=${REPO}
-# echo BRANCH=${BRANCH}
-# echo COMMAND=${COMMAND}
-# echo DIR=${DIR}
-# echo FORCE=${FORCE}
-
- if [ ${REPO} ]; then
- if ! [ -e "${WORKSPACE_DIR}/${DIR}" ] ; then
- git clone -b ${BRANCH} ${REPO} "${WORKSPACE_DIR}/${DIR}"
- FORCE=1
- fi
- if [ "${FORCE}" ] || check_for_remote_changes "${WORKSPACE_DIR}/${DIR}" "${BRANCH}"; then
- pushd "${WORKSPACE_DIR}/${DIR}"
- git pull origin ${BRANCH} # Pull the latest changes
- ${COMMAND}
- popd
- fi
- fi
-}
-
-mkdir -p "${WORKSPACE_DIR}"
-
-if [ $# -gt 0 ] ; then
- for i in $@ ; do
- trigger "${JOB_DIR}/$i" 1
- done
-else
- for i in ${JOB_DIR}/* ; do
- trigger "$i"
- done
-fi