This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# deployedCommits for https://deployer.org/ | |
# created by marjuqi, nov 2019 | |
# 1. this script is designed to fetch commits in each releases folder. | |
# the final output will be stored in file deployedCommits.log | |
# 2. in the beginning of the setup, just create a dump latestCommitID.log file: | |
# cd /var/www/sites/PROJECT_NAME/ && echo 123456789 > latestCommitID.log | |
# go to the currect version of the codes | |
projectFolder=/var/www/sites/PROJECT_NAME/ | |
cd $projectFolder'current/' | |
# extract 50 latest commits from the source code and then store them into file commits.log | |
git log –pretty=oneline | grep -v "Merge" | head -n 50 > commits.log | |
# get the commitID in the first line of commits.log content and then store it into latestCommitID.log | |
head -1 commits.log | awk '{print $1}' > latestCommitID.log | |
# get latestCommitID as a commits limit | |
cd $projectFolder && latestCommitID=`cat latestCommitID.log` | |
# fetch new commits ID from the current deployment until the commits-limit reached, | |
# and then stored them into deployedCommits.log file | |
cd $projectFolder'current' && sed "/$latestCommitID/q" commits.log > deployedCommits.log | |
# update our latestCommitID.log, now it holds the very latest commit ID | |
cp -a latestCommitID.log $projectFolder'latestCommitID.log' | |
# in the end, every release folder has a file called "deployedCommits.log" | |
# thanks. |