Programming/기본 (Baisc)

[Git][깃][자동 push][Git push] Git 자동 Push

YH.Dream 2022. 4. 3. 15:35

1. 개요

 git을 구성하다보면 SSH로 자동화 하는 케이스도 있지만, 계정을 통해 부득이하게 Git push를 해야하는 경우도 존재한다.

 이를 조금 더 효율적이고 많은 Git Repository를 구성하기 위해 다음과 같이 개발한다.

 

2. 조치

#!/bin/bash

gitList=( `find /data/yona/repo/git -name *.git -type d` )

echo "Start -- Git List"

function nowdate() {
    echo `date "+%Y-%m-%d"`
}

while true
do
    for gitDir in "${gitList[@]}"; 
    do 
        NOW_DATE=`nowdate`
        nohup echo "Git Push -- ${gitDir}" >> /applog/git/console.log.${NOW_DATE}; \
        cd "$gitDir"; \
        /app/monitor/git_push_all "${gitDir}" 2>&1 >> /applog/git/console.log.${NOW_DATE} &
        sleep 0.1
    done
    sleep 30
done