Deployment for only the theme directoy

If you have a WordPress website, the core, most plugins and standaard themes are developed by someone else and you never change those files. So it makes no sense to track changes for them in GIT.

I would like to deploy only the (child) theme and maybe some site specific (self written) plugins.

Is this possible with deployment hooks? Instead of excluding a single directory, just include only single directories?

I did some tests with a child repository. On the “code repository” tab from the settings, there is a field for the app folder. Is this maybe the function I need to use?
My site is installed into “/home/user/domain.com/current/public/”. What kind of value should I use?
The value from the screenshot doesn’t work…

Keeping that field empty, creates the app but it also removes the whole public folder which holds the unversioned website.

Hi @finalwebsites ,

I had an similar situation but the exact other way around, i had a folder that i wanted to keep out of git since there were all stuff my customer uploaded so the “git files protect” didn´t work,

So i got help to create an deploy hook that made the folder lie permanent outside cleavr´s deploy versoning system.

Maybe this can give you some ideas?

SHARED_DIR=upload
echo 'Checking the shared directory...'
if [ -d "{{ projectPath }}/$SHARED_DIR" ]; then
  echo 'Found an existing shared directory.'
else
  mkdir -p "{{ projectPath }}/$SHARED_DIR"
  chown -R {{ username }}:www-data "{{ projectPath }}/$SHARED_DIR"
  chmod -R 775 "{{ projectPath }}/$SHARED_DIR"
fi

# remove the storage folder if exists
if [ -d "{{ releasePath }}/public/$SHARED_DIR" ]; then
    echo "Shared directory {{ releasePath }}/public/$SHARED_DIR is pushed. To make data persists across deployments, removing this directory and linking it to {{ projectPath }}/$SHARED_DIR instead."
    rm -rf "{{ releasePath }}/public/$SHARED_DIR"
fi

echo 'Linking the shared folder...'
ln -s "{{ projectPath }}/$SHARED_DIR" "{{ releasePath }}/public/$SHARED_DIR"
1 Like

We never thought of having someone use deployment with a WordPress site. Interesting use case.

What type are you using to being with? We don’t support deployments for WP sites so I guess you are using PHP?

There are a couple of WordPress-development focused solutions out there such as WordPlate (Deploy WordPlate Wordpress Sites - Cleavr docs) and BedRock (Deploy Bedrock Wordpress Sites - Cleavr docs) which I provided links to our guides. These would use the PHP app type.

The question is interesting though since in this use case it sounds like @finalwebsites wants to keep WordPress mostly static but then just deploy to a single directory…

The short answer is we don’t have a way to do that exactly in Cleavr. This is because every deployment we pull down the whole repo into a new directory, build it, and then make it live.

For this particular use case, you’d have to set up a separate web app (probably using the ‘plain html’ type) and pull just the sub-directory from the repo like in the screenshot above, and then make a custom deployment hook that copies and pastes to the appropriate directory in the static app…

I hope that makes sense.

Actually, this doesn’t sound much different than what @Matthi is asking for in Missing documentation on and code examples of webhooks and build hooks.

Definitely seems like something for us to put some more thought into.

Hey @peterc,
this is inspiring for my case where I could need some custom hooks: Missing documentation on and code examples of webhooks and build hooks

Thank you very much.

2 Likes

Hi Peter,
Right I used this for other projects as well and it works perfectly for single folders.

1 Like

Yes, of course a PHP app, I installed WP using WP CLI. I can’t choose a WP site for an app in Cleavr :wink:

It’s not for a static website. I have several customers with a lot of custom code which is stored in a child theme. If you use WordPress you never change the code for Plugins, standaard themes and the core, that’s why it doesn’t make sense to version control them in your website project.

I’m not sure if a partly deployment would work because you need also a staging site to test all the (plugin) updates.

The two examples (WordPlate and Bedrock) are complete site deployments. This might work but your deployment is huge in many case while your development work is only small.

Maybe it’s easier to create a ZIP file from you modified child theme and install it over the old version. This should work and is the “regular WordPress way” how stuff is done.