- You can use the command line
- You're using separate GitHub repositories for the umbrella and for the child theme
- You have INN's deploy tools set up on your computer
- as part of this, you have a python virtualenv set up that contains the deploy tool's required python modules, accessible by running
workon largo
. Ifworkon largo
returns an error, runworkon
to get a list of available submodules.
- as part of this, you have a python virtualenv set up that contains the deploy tool's required python modules, accessible by running
- running
env | grep RNS
on your computer shows entries for staging's password, host, and username
pull: the git verb for copying the commits from the upstream repository and making sure your local branch is up-to-date with the latest commits from other people's work.
push: the git verb for taking a set of commits that are on your computer and copying them to the upstream repository
upstream: the git adjective for the authoritative location of a repository
repository: the git noun for a place that contains a bunch of git commits and the branches they live in. GitHub hosts repositories. An example of a repository is https://github.com/religionnews/theme-rns
submodule: the git noun for a git repository that is part of a larger repository. When talking about the relationship between a submodule and the repository that a submodule is part of, the latter is usually called a 'parent'. Submodules have different upstream repositories than their parent repositories, because they are different repositories. The parent repository considers the submodule as a normal file, and tracks which commit the submodule is checked out at.
deploy: The process of copying files from your computer to a server, be that server named 'production' or 'staging'
Umbrella: the INN noun for a particular type of parent repository and its submodules, which describe the themes and plugins and other unique parts of a WordPress install.
when committing work in a theme or in the umbrella, make sure that you are on a branch. If when you run git status
, it says something like HEAD detached at ec0a720
, you are not on a branch. You should run git checkout master
, where master
is a branch name, and then commit your changes on that branch.
If you are switching branches, and have changes that are not currently committed, you can run git stash
to stash the changes, git checkout master
to switch to the branch you want to switch to, and then git stash apply
to apply the stashed changes to the branch. Then you will want to commit, because committing saves your changes to the repository, and then you will want to push, so that other people can see and use your changes.
If you do not want to do work in the master
branch, run git checkout -b cheese
to switch to the new branch cheese
.
When you want to merge the changes from the cheese
branch into master
, run:
git checkout master
git pull
git merge cheese
-
First, open a terminal. We'll be keeping track of where you are with the text to the left of the
$
prompt character. Anything to the right of the$
is what you would enter into your terminal.- for example, here
~/foo
is the current directory,$
is the prompt, andls
is the command to run:~/foo$ ls
~
is a special directory name: it is your user's home directory.
- for example, here
-
Move to where your umbrella repository is. These docs assume that it's at
~/vms/rns-umbrella/
~$ cd ~/vms/rns-umbrella/
-
Make sure you're in the right spot by running
ls
. You should see something like this:~/vms/rns-umbrella$ ls Vagrantfile migrate_subsites.sh wp-blog-header.php wp-load.php archive_export.sh migration.md wp-comments-post.php wp-login.php archive_import.sh migration_lib.sh wp-config-sample.php wp-mail.php fabfile.py readme.html wp-config.php wp-settings.php fabfile.pyc requirements.txt wp-content wp-signup.php index.php tools wp-cron.php wp-trackback.php license.txt wp-activate.php wp-includes xmlrpc.php migrate_ee.sh wp-admin wp-links-opml.php
-
Now change directories into the child theme, where you have already made some edits:
~/vms/rns-umbrella$ cd wp-content/themes/rns ~/vms/rns-umbrella/wp-content/themes/rns$ git status On branch benlk-writing-docs Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: README.md no changes added to commit (use "git add" and/or "git commit -a")
-
Commit the changes to your current branch
benlk-writing-docs
~/vms/rns-umbrella/wp-content/themes/rns$ git commit -a -m "Commit message goes here" [benlk-writing-docs 9d238a3] Commit message goes here 1 file changed, 1 insertion(+), 1 deletion(-)
-
Make sure that you have the most-recent changes from other people's work in the same branch:
~/vms/rns-umbrella/wp-content/themes/rns$ git pull
-
Push your branch
benlk-writing-docs
's changes to the upstream repository for the theme:~/vms/rns-umbrella/wp-content/themes/rns$ git push -u origin benlk-writing-docs Counting objects: 3, done. Delta compression using up to 4 threads. Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 304 bytes | 0 bytes/s, done. Total 3 (delta 2), reused 0 (delta 0) remote: Resolving deltas: 100% (2/2), completed with 2 local objects. To git@github.com:religionnews/theme-rns.git * [new branch] benlk-writing-docs -> benlk-writing-docs Branch benlk-writing-docs set up to track remote branch benlk-writing-docs from origin.
-
Now we're going to update the parent umbrella repository so it tracks the changes to the submodule. We're doing to do this on the
staging
branch of the umbrella repository, so that we can deploy the umbrella repository to the staging server. -
First, get back up to the umbrella repository
~/vms/rns-umbrella/wp-content/themes/rns$ cd ../../../ ~/vms/rns-umbrella$ git status On branch master Your branch is up-to-date with 'origin/master'. Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: wp-content/themes/rns (new commits) Untracked files: (use "git add <file>..." to include in what will be committed) wp-content/db.php no changes added to commit (use "git add" and/or "git commit -a")
-
In the above output of running
git status
, you can see that we're on themaster
branch. Let's switch tostaging
~/vms/rns-umbrella$ git checkout staging M wp-content/plugins/analytic-bridge M wp-content/plugins/link-roundups M wp-content/plugins/rns-edd-mods M wp-content/plugins/super-cool-ad-inserter-plugin M wp-content/themes/largo M wp-content/themes/rns Switched to branch 'staging'
-
In the above output, every line starting with
M
is a modified file or submodule. There's a command that will go into each submodule and check out the commit that thestaging
branch of the umbrella repository thinks the submodules should be checked out at, but first let's make sure that that command doesn't change the child theme that we're updating, by adding it as a change that will be committed:~/vms/rns-umbrella$ git add wp-content/themes/rns On branch staging Your branch is up-to-date with 'origin/staging'. Changes to be committed: (use "git reset HEAD <file>..." to unstage) modified: wp-content/themes/rns Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: wp-content/plugins/analytic-bridge (new commits) modified: wp-content/plugins/link-roundups (new commits) modified: wp-content/plugins/rns-edd-mods (new commits) modified: wp-content/plugins/super-cool-ad-inserter-plugin (new commits) modified: wp-content/themes/largo (new commits)
-
And let's make sure that this repository is also up to date:
~/vms/rns-umbrella$ git pull
-
Not all the "Changes not staged for commit" lines that say
(new commits)
. Those are the submodules that need to be updated. Let's clean those up:~/vms/rns-umbrella$ git submodule update --init --recursive Submodule path 'wp-content/plugins/analytic-bridge': checked out '193fd8df64f64d5b79edc3a0fda4f18e7d66d668' Submodule path 'wp-content/plugins/link-roundups': checked out '95bbe9c3de84bd1b4db626a852c032c4b15ecedf' Submodule path 'wp-content/plugins/rns-edd-mods': checked out '9287a1ffe3dd5ac9df1379039d0cb8f0812ee442' Submodule path 'wp-content/plugins/super-cool-ad-inserter-plugin': checked out 'ab2b517e407e47dfea8616eb562362ba58a8a9ad' Submodule path 'wp-content/themes/largo': checked out '2db29eba081d53cb334ca30334f826135f8e4703' ~/vms/rns-umbrella$ git status On branch staging Your branch is up-to-date with 'origin/staging'. Changes to be committed: (use "git reset HEAD <file>..." to unstage) modified: wp-content/themes/rns
-
Now that the submodules are checked out properly, it's time to commit our changes
~/vms/rns-umbrella$ git commit -m "This is your commit message" [staging 8b4ad94] this is your commit message 1 file changed, 1 insertion(+), 1 deletion(-)
-
And push them to the upstream remote for the umbrella repository.
~/vms/rns-umbrella$ git push -u origin staging Counting objects: 3, done. Delta compression using up to 4 threads. Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 304 bytes | 0 bytes/s, done. Total 3 (delta 2), reused 0 (delta 0) remote: Resolving deltas: 100% (2/2), completed with 2 local objects. To git@github.com:religionnews/umbrella-rns.git staging -> staging Branch staging set up to track remote branch staging from origin.
-
We've pushed the changes for the child theme and the umbrella repository to their respective upstream repositories, so now everyone can see the changes.
-
It's time to deploy. Let's apply the virtualenv, so that we can run the deploy tools. It'll add a
(rns)
decoration on your command-line prompt, so that you know you're using the virtualenv.~/vms/rns-umbrella$ workon largo (rns)~/vms/rns-umbrella$
-
To deploy, you must be at the top level of the umbrella. If you've been following along thus far, you should be there, but let's make sure by comparing the output of a git command with the current directory:
(rns)~/vms/rns-umbrella$ pwd /Users/you/vms/rns (rns)~/vms/rns-umbrella$git rev-parse --show-toplevel /Users/you/vms/rns
-
Looks like we're good on that front. Do we have the parts needed to deploy?
(rns)~/vms/rns-umbrella$ fab wp.verify_prerequisites [localhost] Executing task 'wp.verify_prerequisites' Verifying your installation of curl supports sftp... Your installation of curl supports sftp! Ensuring you have git-ftp installed... You have git-ftp installed! Your system is ready to deploy code! Done.
-
Yes, we have the software needed to deploy. Okay, now to do a dry-run of the deploy, to make sure that some other moving parts are in place without actually changing anything. We're telling
fab
that to the staging server, with the branch 'staging', as a dry run, it should deploy:(rns)~/vms/rns-umbrella$ fab staging branch:staging dry_run deploy ( A lot of stuff scrolls past. Hopefully it succeeds! )
-
Time to actually deploy:
(rns)~/vms/rns-umbrella$ fab staging branch:staging deploy ( A lot of stuff scrolls past. Hopefully it succeeds! )
And that's how you deploy.