The deployment script now uses the current revision of the set branch in this case. Does not work together with a custom value of $CONFIG_HASH_LENGTH though.
@ -33,11 +33,15 @@ This is a tutorial on how you would implement this setup with this toolset.
Using `project_add` is similar, but it uses a custom project path – the headers of the files in `bin/` contain detailed usage information.
3. **Get the current state from your GitHub repository (other Git repositories work the same)**
As "main_site" was setup using a clone URL, you can use `site_deploy <site> <revision>` to get and install the current state of your project:
As "main_site" was setup using a clone URL, you can use `site_deploy <site> [<revision>]` to fetch and install the current state of your project automatically:
```bash
site_deploy main_site
```
If you omit the Git revision, the latest one is used instead. But if you want to deploy a specific revision, that's easy too:
```bash
# You need the full SHA-1 hash of your commit for this to work.
# Automatic deployments using web hooks do this for you automatically.
# Check if the default value for $CONFIG_HASH_LENGTH has been changed
if [[ $CONFIG_HASH_LENGTH != 40 ]]; then
echo -e "\033[31mYou changed the default value of \033[34m\$CONFIG_HASH_LENGTH\033[31m. To make sure the deployed revisions are unique and never duplicated, deployments of the latest revision aren't supported with a custom value of this option. Please give me the exact revision string in your custom length.\033[0m" >&2
exit 1
fi
fi
# Check if the project exists
if [[ ! -f "$project/.project" ]]; then
@ -74,12 +84,6 @@ if [[ ! -f "$project/.origin" ]]; then
exit 1
fi
# Check if the commit hash is valid
if [[ ${#revision} != $CONFIG_HASH_LENGTH ]]; then
echo -e "\033[31mThe length of the revision name \033[34m$revision\033[31m is not equal to the configured \033[34m$CONFIG_HASH_LENGTH\033[31m characters.\033[0m" >&2
exit 1
fi
# Add header to log
log="$project/logs/$revision.log"
if [[ -f "$log" ]]; then
@ -90,18 +94,9 @@ echo -e "\033[1;35mRun on \033[34m$(date)\033[35m by \033[34m$USER\033[35m:\n---
# Log everything beginning here
{
# Check if we already installed this version
if ls "$project/versions"/*-$revision &> /dev/null; then
echo -e "\033[1mThis revision has already been installed, using previous installation \033[34m$versionName\033[0;1m.\033[0m"
else
# No, fetch and install
# Make sure the repository exists and is updated
# We only need to do this if the revision was not deployed yet
if ! ls "$project/versions"/*-$revision &> /dev/null; then
# Check if the repository has already been cloned
url=$(cat "$project/.origin")
if ! [[ -d "$project/repo" ]]; then
@ -121,6 +116,45 @@ echo -e "\033[1;35mRun on \033[34m$(date)\033[35m by \033[34m$USER\033[35m:\n---
fi
echo -e " => \033[32mSuccess.\033[0m"
fi
fi
# Determine the actual revision to use
if [[ "$revision" != "latest" ]]; then
# Check if the given commit hash is valid
if [[ ${#revision} != $CONFIG_HASH_LENGTH ]]; then
echo -e "\033[31mThe length of the revision name \033[34m$revision\033[31m is not equal to the configured \033[34m$CONFIG_HASH_LENGTH\033[31m characters.\033[0m" >&2
exit 1
fi
else
# Check if the set branch exists
branch=$(cat "$project/.branch")
echo -e "\033[1mDetermining current revision for branch \033[34m$branch\033[0;1m...\033[0m"
if ! (cd "$project/repo"; git show-branch "$branch" &> /dev/null); then
echo -e "\033[31mThe set branch \033[34m$branch\033[31m does not exist.\033[0m" >&2
exit 1
fi
# Get the commit hash from the set branch
revision="$(cd "$project/repo"; git show --format=format:%H "$branch")"
if [[ $? != 0 ]]; then
echo -e " => \033[31mCould not determine current revision.\033[0m" >&2