Created
February 4, 2020 00:34
-
-
Save hiro08gh/6051719d3c0afea30d59b97a7994dc6f to your computer and use it in GitHub Desktop.
デプロイシェル
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
# $ chmode 755 deploy.sh | |
# $ ./deploy.sh | |
#!/bin/bash | |
set -e | |
CLONE_TO=/path/to/clone | |
REPO_URL=git@github.com:hiro08gh/repos.git | |
BRANCH=master | |
echo git clone | |
if [ -d "$CLONE_TO" ]; then | |
cd $CLONE_TO | |
git fetch -p | |
git checkout -q $BRANCH | |
latest_rev=$(git ls-remote origin HEAD | awk '{print $1}') | |
current_rev=$(git rev-parse HEAD) | |
if [ "$latest_rev" != "$current_rev" ]; then | |
git reset --hard $(git log --pretty=format:%H | tail -1) | |
git pull | |
fi | |
else | |
git clone $REPO_URL $CLONE_TO | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment