Remove most parameters for easier usage
This commit is contained in:
parent
cc0591e279
commit
84f2e1b75f
|
@ -1,27 +1,31 @@
|
|||
#!/usr/local/bin/bash
|
||||
# $1 = source
|
||||
# $2 = destination
|
||||
# $3 = temp dir
|
||||
# $1 = destination
|
||||
|
||||
repo_dir="$(git rev-parse --git-dir)"
|
||||
repo_name="$(basename -s .git "$(git rev-parse --git-dir)")"
|
||||
dst_dir="$1"
|
||||
tmp_dir="$HOME/tmp/git/$repo_name-$(date +%s)"
|
||||
|
||||
echo "[[ Deploy ]] jekyll($repo_name)"
|
||||
echo "[[ Deploy ]] src: '$repo_dir'"
|
||||
echo "[[ Deploy ]] dst: '$dst_dir'"
|
||||
echo "[[ Deploy ]] tmp: '$tmp_dir'"
|
||||
|
||||
if test -e "$tmp_dir"; then
|
||||
echo "[[ Deploy ]] Directory '$tmp_dir' already exists, stopping deployment."
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
echo "[[ Deploy ]] jekyll: $1 $2 $3"
|
||||
echo "[[ Deploy ]] Creating directories '$dst_dir' and '$tmp_dir'."
|
||||
mkdir -p "$dst_dir" "$tmp_dir"
|
||||
|
||||
while [ -e "$3" ]
|
||||
do
|
||||
echo "[[ Deploy ]] Waiting for another process to finish deploying..."
|
||||
sleep 3
|
||||
done
|
||||
echo "[[ Deploy ]] Cloning repository at '$repo_dir' into '$tmp_dir'."
|
||||
git clone "$repo_dir" "$tmp_dir"
|
||||
|
||||
echo "[[ Deploy ]] Building Jekyll at '$tmp_dir' into '$dst_dir'."
|
||||
jekyll build --source "$tmp_dir" --destination "$dst_dir"
|
||||
chmod -R g+w "$dst_dir"
|
||||
|
||||
echo "[[ Deploy ]] Creating directories '$2' and '$3'"
|
||||
mkdir -p "$2" "$3"
|
||||
|
||||
echo "[[ Deploy ]] Cloning repository at '$1' into '$3'"
|
||||
git clone "$1" "$3"
|
||||
|
||||
echo "[[ Deploy ]] Building Jekyll at '$3' into '$2'"
|
||||
jekyll build --source "$3" --destination "$2"
|
||||
chmod -R g+w "$2"
|
||||
|
||||
echo "[[ Deploy ]] Deleting '$3'"
|
||||
rm -rf "$3"
|
||||
echo "[[ Deploy ]] Deleting '$tmp_dir'"
|
||||
rm -rf "$tmp_dir"
|
||||
|
|
50
deploy-npm
50
deploy-npm
|
@ -1,32 +1,36 @@
|
|||
#!/usr/local/bin/bash
|
||||
# $1 = source
|
||||
# $2 = destination
|
||||
# $3 = temp dir
|
||||
# $1 = destination
|
||||
|
||||
repo_dir="$(git rev-parse --git-dir)"
|
||||
repo_name="$(basename -s .git "$(git rev-parse --git-dir)")"
|
||||
dst_dir="$1"
|
||||
tmp_dir="$HOME/tmp/git/$repo_name-$(date +%s)"
|
||||
|
||||
echo "[[ Deploy ]] static($repo_name)"
|
||||
echo "[[ Deploy ]] src: '$repo_dir'"
|
||||
echo "[[ Deploy ]] dst: '$dst_dir'"
|
||||
echo "[[ Deploy ]] tmp: '$tmp_dir'"
|
||||
|
||||
if test -e "$tmp_dir"; then
|
||||
echo "[[ Deploy ]] Directory '$tmp_dir' already exists, stopping deployment."
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
echo "[[ Deploy ]] npm: $1 $2 $3"
|
||||
echo "[[ Deploy ]] Creating directories '$dst_dir' and '$tmp_dir'."
|
||||
mkdir -p "$dst_dir" "$tmp_dir"
|
||||
|
||||
while [ -e "$3" ]
|
||||
do
|
||||
echo "[[ Deploy ]] Waiting for another process to finish deploying..."
|
||||
sleep 3
|
||||
done
|
||||
echo "[[ Deploy ]] Cloning repository at '$repo_dir' into '$tmp_dir'."
|
||||
git clone "$repo_dir" "$tmp_dir"
|
||||
|
||||
|
||||
echo "[[ Deploy ]] Creating directories '$2' and '$3'"
|
||||
mkdir -p "$2" "$3"
|
||||
|
||||
echo "[[ Deploy ]] Cloning repository at '$1' into '$3'"
|
||||
git clone "$1" "$3"
|
||||
|
||||
echo "[[ Deploy ]] Deploying npm at '$3' into '$3/dist'"
|
||||
cd "$3" || exit
|
||||
echo "[[ Deploy ]] Deploying npm at '$tmp_dir' into '$tmp_dir/dist'."
|
||||
cd "$tmp_dir" || exit
|
||||
npm ci
|
||||
npm run deploy
|
||||
|
||||
echo "[[ Deploy ]] Copying files from '$3/dist' to '$2'"
|
||||
cp -r dist/ "$2"
|
||||
chmod -R g+w "$2"
|
||||
echo "[[ Deploy ]] Copying files from '$tmp_dir/dist' to '$dst_dir'."
|
||||
cp -r dist/ "$dst_dir"
|
||||
chmod -R g+w "$dst_dir"
|
||||
|
||||
echo "[[ Deploy ]] Deleting '$3'"
|
||||
rm -rf "$3"
|
||||
echo "[[ Deploy ]] Deleting '$tmp_dir'."
|
||||
rm -rf "$tmp_dir"
|
||||
|
|
|
@ -1,28 +1,32 @@
|
|||
#!/usr/local/bin/bash
|
||||
# $1 = source
|
||||
# $2 = destination
|
||||
# $3 = temp dir
|
||||
# $1 = destination
|
||||
|
||||
repo_dir="$(git rev-parse --git-dir)"
|
||||
repo_name="$(basename -s .git "$(git rev-parse --git-dir)")"
|
||||
dst_dir="$1"
|
||||
tmp_dir="$HOME/tmp/git/$repo_name-$(date +%s)"
|
||||
|
||||
echo "[[ Deploy ]] static($repo_name)"
|
||||
echo "[[ Deploy ]] src: '$repo_dir'"
|
||||
echo "[[ Deploy ]] dst: '$dst_dir'"
|
||||
echo "[[ Deploy ]] tmp: '$tmp_dir'"
|
||||
|
||||
if test -e "$tmp_dir"; then
|
||||
echo "[[ Deploy ]] Directory '$tmp_dir' already exists, stopping deployment."
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
echo "[[ Deploy ]] static: $1 $2 $3"
|
||||
echo "[[ Deploy ]] Creating directories '$dst_dir' and '$tmp_dir'."
|
||||
mkdir -p "$dst_dir" "$tmp_dir"
|
||||
|
||||
while [ -e "$3" ]
|
||||
do
|
||||
echo "[[ Deploy ]] Waiting for another process to finish deploying..."
|
||||
sleep 3
|
||||
done
|
||||
echo "[[ Deploy ]] Cloning repository at '$repo_dir' into '$tmp_dir'."
|
||||
git clone "$repo_dir" "$tmp_dir"
|
||||
rm -rf "$tmp_dir/.git/"
|
||||
|
||||
echo "[[ Deploy ]] Copying files from '$tmp_dir' to '$dst_dir'."
|
||||
cp -r "$tmp_dir" "$dst_dir"
|
||||
chmod -R g+w "$dst_dir"
|
||||
|
||||
echo "[[ Deploy ]] Creating directories '$2' and '$3'"
|
||||
mkdir -p "$2" "$3"
|
||||
|
||||
echo "[[ Deploy ]] Cloning repository at '$1' into '$3'"
|
||||
git clone "$1" "$3"
|
||||
rm -rf "$3/.git/"
|
||||
|
||||
echo "[[ Deploy ]] Copying files from '$3' to '$2'"
|
||||
cp -r "$3" "$2"
|
||||
chmod -R g+w "$2"
|
||||
|
||||
echo "[[ Deploy ]] Deleting '$3'"
|
||||
rm -rf "$3"
|
||||
echo "[[ Deploy ]] Deleting '$tmp_dir'."
|
||||
rm -rf "$tmp_dir"
|
||||
|
|
|
@ -1,24 +1,29 @@
|
|||
#!/usr/local/bin/bash
|
||||
# $1 = source repository
|
||||
# $2 = destination repository, including tokens
|
||||
# $3 = temp dir
|
||||
|
||||
repo_url="$1"
|
||||
repo_name="$(basename -s .git "$repo_url")"
|
||||
dst_url="$2"
|
||||
tmp_dir="$HOME/tmp/git/$repo_name-$(date +%s)"
|
||||
|
||||
echo "[[ Deploy ]] mirror-to-github($repo_name)"
|
||||
echo "[[ Deploy ]] src: '$repo_url'"
|
||||
echo "[[ Deploy ]] dst: '$dst_url'"
|
||||
echo "[[ Deploy ]] tmp: '$tmp_dir'"
|
||||
|
||||
if test -e "$tmp_dir"; then
|
||||
echo "[[ Deploy ]] Directory '$tmp_dir' already exists, stopping deployment."
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
echo "[[ Deploy ]] mirror-to-github: $1 $2 $3"
|
||||
echo "[[ Deploy ]] Bare cloning repository at '$repo_url' into '$tmp_dir'."
|
||||
git clone --bare "$repo_url" "$tmp_dir"
|
||||
|
||||
while [ -e "$3" ]
|
||||
do
|
||||
echo "[[ Deploy ]] Waiting for another process to finish deploying..."
|
||||
sleep 3
|
||||
done
|
||||
echo "[[ Deploy ]] Mirroring repo at '$tmp_dir' into '$dst_url'."
|
||||
cd "$tmp_dir" || exit
|
||||
git push --mirror "$dst_url"
|
||||
|
||||
|
||||
echo "[[ Deploy ]] Bare cloning repository at '$1' into '$3'"
|
||||
git clone --bare "$1" "$3"
|
||||
|
||||
echo "[[ Deploy ]] Mirroring repo at '$3' with '$2'"
|
||||
cd "$3" || exit
|
||||
git push --mirror "$2"
|
||||
|
||||
echo "[[ Deploy ]] Deleting '$3'"
|
||||
rm -rf "$3"
|
||||
echo "[[ Deploy ]] Deleting '$tmp_dir'."
|
||||
rm -rf "$tmp_dir"
|
||||
|
|
Loading…
Reference in New Issue