Skip to content
This repository was archived by the owner on Jan 25, 2022. It is now read-only.

Commit 0d73ce1

Browse files
committed
Further refinement of pantheon-deploy
1 parent adfaaf6 commit 0d73ce1

File tree

1 file changed

+30
-53
lines changed

1 file changed

+30
-53
lines changed

guest/cli/commands/pantheon-deploy

Lines changed: 30 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -50,50 +50,44 @@ if [ "" == "${git_url}" ]; then
5050
return 5
5151
fi
5252

53-
echo_if_not_quiet "$*" "^Deploying to the ${target_domain} ${deploy_host} server at Pantheon..."
53+
echo_if_not_quiet "$*" "=Beginning deploy to '${deploy_host}' server for ${target_domain} at Pantheon..."
5454

5555
#
5656
# Create temporary directories to work in
5757
# See Method # 2 Use of $$ variable:
5858
# - http://www.cyberciti.biz/tips/shell-scripting-bash-how-to-create-temporary-random-file-name.html
5959
#
60-
clone_dir="${HOME}/build/${target_domain}/pantheon-clone"
61-
upstream_dir="${HOME}/build/pantheon-upstream"
60+
clone_dir="${HOME}/.wplib.box.cache/${target_domain}/pantheon-clone"
61+
upstream_dir="${HOME}/.wplib.box.cache/pantheon-upstream"
6262
build_dir="/tmp/deploy-build.$$.dir"
6363

6464
#
6565
# Clone the site from our repo on Pantheon
6666
#
67-
echo_if_not_quiet "$*" "=Cloning from ${deploy_host}'s Git repo..."
68-
ensure_git_clone "${git_url}" "${clone_dir}" || return $?
67+
echo_if_not_quiet "$*" "=Cloning/revising clone of ${target_domain}'s Git repo at Pantheon..."
68+
ensure_git_clone "${git_url}" "${clone_dir}" --quiet || return $?
6969

7070
#
7171
# Clone the pristine Pantheon Upstream
7272
#
73-
echo_if_not_quiet "$*" "&Cloning from the Pantheon upstream Git repo..."
74-
git clone https://github.com/pantheon-systems/WordPress "${upstream_dir}" || return $?
75-
cp "${upstream_dir}" "${build_dir}" || return ?*
73+
echo_if_not_quiet "$*" "=Cloning/revising clone of Pantheon's WordPress upstream Git repo..."
74+
ensure_git_clone https://github.com/pantheon-systems/WordPress "${upstream_dir}" --quiet || return $?
7675

7776
#
78-
# Copy the pristine upstream to the build dir
77+
# Copy the upstream to the build directory
7978
#
80-
echo_if_not_quiet "$*" "&Copying the Pantheon upstream to local build dir..."
81-
git clone https://github.com/pantheon-systems/WordPress "${upstream_dir}" || return $?
82-
cd -R "${upstream_dir}" || return ?*
83-
84-
echo_if_not_quiet "$*" "&Cleaning the pantheon-systems/WordPress Git repo..."
79+
echo_if_not_quiet "$*" "=Copying Pantheon's WordPress upstream to build directory..."
80+
cp -RP "${upstream_dir}" "${build_dir}" || return ?*
8581

82+
echo_if_not_quiet "$*" "=Removing '.git' and 'wp-content' sub-directories from build directory..."
8683
#
8784
# Erase the .git that points to Pantheon's pristine Upstream repo
85+
# AND Rip out it's content directory
8886
#
8987
rm -rf "${build_dir}/.git" || return ?*
90-
91-
#
92-
# Rip out it's content directory
93-
#
9488
rm -rf "${build_dir}/wp-content" || return ?*
9589

96-
echo_if_not_quiet "$*" "=Copying content directories from dev..."
90+
echo_if_not_quiet "$*" "=Copying content directories from /var/www to build directory..."
9791
#
9892
# Replace with our content directory
9993
#
@@ -103,106 +97,89 @@ cp -RP "${WPLIB_BOX_CONTENT_DIR}/" "${build_dir}/wp-content" || return ?*
10397
# If there is a /vendor directory, don't forget it
10498
#
10599
if [[ -d "${WPLIB_BOX_VENDOR_DIR}" ]]; then
106-
echo_if_not_quiet "$*" "=Copying vendor directories from dev..."
100+
echo_if_not_quiet "$*" "=Copying vendor directories from /var/www to build directory..."
107101
cp -RP "${WPLIB_BOX_VENDOR_DIR}/" "${build_dir}/vendor" || return ?*
108102
fi
109103

110104
#
111105
# If there is a /pantheon.yaml, don't forget it
112106
#
113107
if [ -f "${WPLIB_BOX_DIR}/pantheon.yaml" ]; then
114-
echo_if_not_quiet "$*" "=Copying pantheon.yaml from dev..."
108+
echo_if_not_quiet "$*" "=Copying pantheon.yaml from /vagrant..."
115109
cp "${WPLIB_BOX_DIR}/pantheon.yaml" "${build_dir}/pantheon.yaml"
116110
fi
117111

118112
#
119113
# Strip .git "submodules"
120114
#
121-
echo_if_not_quiet "$*" "&Stripping Git submodule references..."
115+
echo_if_not_quiet "$*" "=Stripping Git submodule references in build directory..."
122116
find "${build_dir}" -name .git | xargs rm -fr || return ?*
123117
find "${build_dir}" -name .gitignore | xargs rm -fr || return ?*
124118
find "${build_dir}" -name .gitattributes | xargs rm -fr || return ?*
125119

126120
#
127121
# Remove these. We do not need these on a hosted site.
128122
#
129-
echo_if_not_quiet "$*" "=Removing items to exclude from ${build_dir}/..."
123+
echo_if_not_quiet "$*" "=Removing items to exclude from build..."
130124
delete_exclude_items "${build_dir}" || return ?*
131125

132126
#
133127
# Remove anything that is in the "require-dev" category
134128
#
135-
echo_if_not_quiet "$*" "&Removing \"require-dev\" items from ${build_dir}/..."
129+
echo_if_not_quiet "$*" "=Removing 'require-dev' items from build..."
136130
$WPLIB_BOX_PHPCLI "${WPLIB_BOX_INCLUDES_DIR}/run-command.php" --args remove-composer-require-dev "${build_dir}" || return ?*
137131

138132
#
139133
# Now get the Pantheon repo's .git dir and make it our own
140134
#
141-
echo_if_not_quiet "$*" "&Copying over .git directory from source..."
142-
mv "${clone_dir}/.git" "${build_dir}" || return ?*
135+
echo_if_not_quiet "$*" "=Copying over .git directory from /vagrant..."
136+
cp -R "${clone_dir}/.git" "${build_dir}" || return ?*
143137

144138
cd "${build_dir}" || return ?*
145-
#
146-
# So we can view after the fact
147-
#
148-
#git status
149139

150140
#
151141
# Delete directories that Pantheon Reserves
152142
#
153-
echo_if_not_quiet "$*" "=Deleting all upload directories that Pantheon-reserves..."
143+
echo_if_not_quiet "$*" "=Deleting all Pantheon-reserved sub-directories from build directory..."
154144
rm -rf "${build_dir}/sites/default/files" || return ?*
155145
rm -rf "${build_dir}/wp-content/uploads" || return ?*
156146
rm -rf "${build_dir}/web/sites/default/files" || return ?*
157147
rm -rf "${build_dir}/web/wp-content/uploads" || return ?*
158148

159-
echo_if_not_quiet "$*" "^Staging all files for commit..."
160149
#
161150
# Add any changes to staging
162151
#
152+
echo_if_not_quiet "$*" "=Staging all files in build directory for commit..."
163153
quiet_git add --all . || return ?*
164154

165-
#
166-
# Add any changes to staging
167-
#
168-
quiet_git add -u || return ?*
169155

170156
#
171-
# So we can view after the fact
172-
#
173-
#git status
174-
175-
echo_if_not_quiet "$*" "=Committing all files to prepare for deployment..."
176-
#
177-
# Merge in any changes
157+
# Commit all changes
178158
#
159+
echo_if_not_quiet "$*" "=Committing all updates in build directory to prepare for deployment..."
179160
quiet_git commit -m "${commit_message}" || return ?*
180161

181162
#
182163
# Now do a pull, just in case.
183164
# It should be up to date though.
184165
#
185-
quiet_git pull --commit --no-edit --no-ff --verbose || return ?*
166+
#echo_if_not_quiet "$*" "=Pulling ..."
167+
#quiet_git pull --commit --no-edit --no-ff --verbose || return ?*
186168

187169
#
188-
# So we can view after the fact
170+
# Push our changes back to Panethon
189171
#
190-
#git status
191-
echo_if_not_quiet "$*" "=Pushing files for ${project_name} to ${deploy_host} at Pantheon..."
172+
echo_if_not_quiet "$*" "=Pushing commit for ${project_name} to '${deploy_host}' at Pantheon..."
192173
#
193174
# Ensure this is already set
194175
#
195176
quiet_git config --global push.default simple || return ?*
196-
197-
#
198-
# Push our changes back to Panethon
199-
#
200177
quiet_git push || return ?*
201178

202-
echo_if_not_quiet "$*" "=Cleaning up..."
179+
echo_if_not_quiet "$*" "=Removing build directory..."
203180
#
204181
# Clean up
205182
#
206183
rm -rf "${build_dir}" || return ?*
207184

208-
echo_if_not_quiet "$*" "&Done."
185+
echo_if_not_quiet "$*" "=Deployment for ${project_name} to '${deploy_host}' at Pantheon is now complete."

0 commit comments

Comments
 (0)