@echo
@echo "all Builds the .buildlist and an index.html. (Top-level)"
@echo "clean Removes build artifacts."
+ @echo "deploy Copies files to destination defined in $(SRC_DIR)/.env"
@echo "help Prints this help message."
@echo ".buildlist Defines a list of all files to build. Paths may be relative."
@echo " to this Makefile's directory. Paths should be on their own lines. You"
@echo " may create this file manually or override the BUILD_LIST variable when"
@echo " you invoke the make command. The default BUILD_LIST is created from MD files"
@echo " found anywhere under the $(SRC_DIR) directory."
+ @echo "$(SRC_DIR)/.env" " Defines your deployment info. If not found, you will be prompted for info."
@echo "init-demo Creates links from demo to $(SRC_DIR) so you can then build it."
@echo "init-altdemo Creates links from demo to $(SRC_DIR) (alternate method) so you can then build it."
@echo "rm-src Deletes symlinks in $(SRC_DIR), checking for non-link data."
-rm .buildlist
rm -rf $(BUILD_DIR)
+.PHONY:
+deploy: $(BUILD_DIR) $(SRC_DIR)/.env
+ . $(SRC_DIR)/.env && \
+ rsync --verbose --recursive --delete \
+ --chown=$$SITE_USER:$$SITE_USER --chmod=755 \
+ $(BUILD_DIR)/* $$SITE_USER@$$SITE_HOST:$$SITE_PATH
+
+$(SRC_DIR)/.env:
+ @scripts/make-env.sh
+
.PHONY:
init-demo:
@if [ -e $(SRC_DIR) ]; then echo "$(SRC_DIR) already exists. Aborting." && exit 1; fi
**Note:** Spaces in filepaths will mess the part where the `BUILD_LIST`
variable is used to create the `.buildlist` file.
+## Deploying Your Project with Make
+
+You can use `make deploy` to deploy your project to a server using `rsync`.
+Jetsam does not handle any server-side setup, like creating a user, adding
+SSH keys, or anything like that. But when that is set up correctly, you can
+use `make deploy`. The first time you run it, it will prompt you for some
+site-specific information like the host, user, and path where you'd like to
+deploy. This creates a `.env` file in your source directory, so you can
+easily deploy different content to different sites.
+
+**WARNING:** If you consider host, user, and path information sensitive, be
+sure to add the `.env` file to your source repo's `.gitignore` file so it isn't
+committed into version control.
+
# Explore the Demo
In the demo below, `>>>` indicates a terminal prompt in which you enter a
--- /dev/null
+#!/bin/sh
+
+ENV_FILE="src/.env"
+
+# $1 = environment variable to set
+# $2 = description of environment variable
+prompt_user() {
+ echo "Enter $1 ($2):"
+ read -r value
+ echo "$1=$value" >> "$ENV_FILE"
+}
+
+# Prompt the user for SITE_HOST, SITE_USER, and SITE_PATH
+if [ ! -f "$ENV_FILE" ]; then
+ prompt_user "SITE_HOST" "url or IP address"
+ prompt_user "SITE_PATH" "path to directory of hosted files"
+ prompt_user "SITE_USER" "owns website directory and files"
+ echo
+ echo "The following values were written to $ENV_FILE:" && echo && cat "$ENV_FILE"
+else
+ echo "$ENV_FILE already found."
+fi
\ No newline at end of file