3 # Get a temporary index file to work with.
4 INDEX="$(mktemp -d)/index"
6 for FILE in $(find build -type f -and -not -name '.*'); do
7 # Add file contents to object database.
8 BLOB_ID=$(git hash-object -w -- "$FILE")
13 env GIT_INDEX_FILE="$INDEX" git update-index \
15 --cacheinfo "${MODE},${BLOB_ID},${NAME}"
18 # Special file: "CNAME" for GitHub pages custom domain.
19 # See: https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site/managing-a-custom-domain-for-your-github-pages-site#configuring-a-subdomain
20 BLOB_ID=$(/bin/echo -n hex.wincent.com | git hash-object -w --stdin)
23 env GIT_INDEX_FILE="$INDEX" git update-index \
25 --cacheinfo "${MODE},${BLOB_ID},${NAME}"
27 # Create tree object from index.
28 TREE_ID=$(env GIT_INDEX_FILE="$INDEX" git write-tree)
32 PARENT=$(git rev-parse refs/heads/gh-pages)
33 SOURCE=$(git describe --always --dirty)
34 COMMIT=$(builtin echo "Build $DATE\n\nFrom $SOURCE." | git commit-tree "$TREE_ID" -p "$PARENT" -F -)
36 git update-ref refs/heads/gh-pages "$COMMIT"
38 echo "Created commit: $(git rev-parse --short "$COMMIT")\n"
40 git log --raw -1 refs/heads/gh-pages
42 if $(git diff --quiet "$COMMIT" "$PARENT"); then
46 echo "\n${BOLD}${RED}WARNING: CREATED EMPTY COMMIT${RESET}\n"
47 echo "If this was in error, reset using:"
48 echo " git update-ref refs/heads/gh-pages $(git rev-parse --short "$PARENT")"