Publish/update a WordPress SVN plugin directly from GitHub

·

·

I learned this recently thanks to Fran Torres‘s live Fran Torres explaining of how to publish directly to WordPress SVN.

What is SVN?

SVN is short for Subversion, and is the version control for WordPress repositories such as the core itself, and also plugins. Once we’ve submitted the WordPress plugin and passed its review process, we can publish.

Without knowing much about it and what I’ve worked with, it’s very tedious, since every time you delete a directory, you can end up breaking the project version control. I’ve never been clear on it myself.

But working with GitHub is wonderful, because thanks to the branches, we can break down our development in a very easy way.

Well, to connect GitHub with the SVN repository, we can use the GitHub Actions.

GitHub Actions

GitHub Actions as their page explains, are intended to automate processes within the production release of a software code.

Workflows can be executed in any GitHub event. In this case we will use the tag creation event. And every time we publish a new release on GitHub, it creates that tag and executes the code that sends the files to SVN.

Our workflow will be to create a release every time we want to publish to WordPress.

Configuring GitHub Actions for publishing to WordPress

For our workflow we will be using the action developed by 10up, an agency dedicated to WordPress, and which they have released for us to use.

github actions wordpress svn

The action you can see it in its GitHub action page, where all the documentation to set it up comes. Next, I’ll show you my ideal setup.

In the source of the repository in the main branch, we create a YML file with the following path:

.github/workflows/deploy.yml

And with the following content:

name: Deploy to WordPress.org
on:
  push:
    tags:
    - "*"
jobs:
  tag:
    name: New tag
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - name: WordPress Plugin Deploy
      uses: 10up/action-wordpress-plugin-deploy@stable
      env:
        SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
        SVN_USERNAME: ${{ secrets.SVN_USERNAME }}

Note that this code assumes that your plugin’s SLUG is the same as the GitHub repository. Which on the other hand, I think is the most appropriate thing to do.

We will need to go to the repository menu to set up our SVN user and password. This is in: Settings > Secrets and add SVN_USERNAME and its value, and SVN_PASSWORD and its value as well.

And then so that we can upload all the files related to the WordPress directory, we will need to create a folder:

/.wordpress-org

With the files we want to share, the plugin images and its resources as screenshots. This is:

banner-1544x500.png
banner-772x250.png
icon-128x128.png
icon-256x256.png
screenshot-1.png
screenshot-2.png

SVG or JPG format can also be used for icons.

So now we would have everything set up. Now every time we create a release, it will run our action and publish to WordPress.org. In the Actions tab, you can see the log of each execution.

github actions examples

As you can see, in the first execution I got an error, and the way I did to solve it was to delete the release and also the tag, to recreate the workflow.

Resources:

6 responses to “Publish/update a WordPress SVN plugin directly from GitHub”

    Mentions

  • 💬 Actualidad para profesionales de WordPress (Edición #205) – Enlace Permanente
  • 💬 David
  • 💬 Closemarketing
  • 💬 Roberto Gallego
  • 💬 WordPress Granada
  • 💬 Closemarketing

Leave a Reply

Your email address will not be published. Required fields are marked *