In my last post, I mentioned about the new WordPress plugin that I recently published to the official repository. I don’t use SVN as much I wanted to, as my work usually revolves around Git and the only time that I am using SVN is when dealing with WordPress.org.

I’ve open-sourced my plugin code on Github so I’ve been researching for the easiest way to keep my WordPress SVN repository for the plugin synced with the changes that I’ve made in Git. In the end, I settled with 10up’s WordPress.org Plugin Deploy Github Action.

If you are unfamiliar with Github Action, think of it as a built-in Github continuous integration and delivery feature that you can trigger on various events. For this 10up’s Action, it’s configured to be executed whenever a new tag is pushed to Github and will automatically synchronize the files to your WordPress plugin SVN repository.

The setup process is fairly simple and will require minimal changes to your existing Git repository. Let’s go through the steps:

  1. Add the .wordpress-org directory for your WordPress assets
  2. Configure the .distignore file
  3. Add the workflow file inside the .github directory
  4. Set up your SVN access in the Github repository settings

Add the .wordpress-org directory for your WordPress assets

This is straightforward. All you need to do is to create a .wordpress-org directory and put your plugin assets (banner, screenshots, etc) inside this folder. During the run, all files in this directory will be automatically copied to the assets directory in your SVN repository. You can use another name if you like, but you’ll need to define it in your environment variables.

Configure the .distignore file

Define all the files and directories that you want to be excluded from the deployment. These are usually those source files that you don’t want to end up in your end-user server. For my plugin, I use Laravel Mix to compile the SASS file to a usable CSS, so I excluded those since it’s no use to the end-user. A sample baseline .distignore recommended by 10up is as follows:

/.wordpress-org
/.git
/.github
/node_modules

.distignore
.gitignore

Add the workflow file inside the .github directory

You can name this file however you want. I choose to name it deploy.yml so the file that I create is located in .github/workflows/deploy.yml. The example workflow file mentioned in the README is a good start and should work out of the box. I only need to make a little modification to the build step by switching from npm run build to npx mix --production. Also, since my Github repository slug is not identical to the one in WordPress.org, I need to override the path by specifying the correct slug via the SLUG environment variables. If yours are identical, then you can skip this step.

Set up your SVN access in the Github repository settings

Lastly, you’ll need to go to the Settings > Secrets in your repository then click the “New repository secret” to add two new secrets, SVN_USERNAME and SVN_PASSWORD. These will be the credentials you use to commit your changes to WordPress.org plugin SVN.

At this point, you should be good to go! Try pushing a new tag into your Github repository, and monitor the deployment progress in the Actions tab.