WordPress plugin CI/CD with Github Actions

WordPress org uses SVN for theme and plugin deployment in ORG. Lots of developers don’t like SVN or they are not familiar with it. But all almost all developers use Git and Github for version control.

Github has an amazing tool called “Github Actions”.
It’s a CI/CD tool. Developers can automate their development and deployment tasks using Github Actions.

So what if, “Developers just push their code in Github and it will be deployed to WordPress ORG repository automatically…”

Sounds like a good deal, isn’t it 🙂
In this article, I will show you, “How to deploy to WordPress org using Github Actions”. Github action has lots of third-party tools for this automation process in their marketplace. For WordPress plugin deployment I will use “WordPress Plugin Deploy”, created by 10up.

Add SVN configs on GitHub repository Settings
On the live GitHub repo, go to Settings > Secrets > New Repository Secret. Here you need to create two secret variables `SVN_PASSWORD` and `SVN_USERNAME`. These are very much self-explanatory just add your SVN password and username for these variables.

deploy.yml file
To create a GitHub action we need to create a .github folder on plugin root and workflows folder in the .github folder.
Now let’s create `deploy.yml` file in `.github/workflows`folder. GitHub will execute this file to run the action. Add this code block in the file. Change `SLUG` according to your plugin slug. It’s a yml file so we need to careful about indentations.

name: Deploy to WordPress.org
    - "*"
    name: New tag
    runs-on: ubuntu-latest
    - uses: actions/checkout@main
    - name: WordPress Plugin Deploy
      uses: 10up/action-wordpress-plugin-deploy@stable
        SVN_PASSWORD: ${{ secrets.WP_SVN_PASS }}
        SVN_USERNAME: ${{ secrets.WP_SVN_USER }}
        SLUG: pluginSlug # optional, remove if GitHub repo name matches SVN slug, including capitalization

Remove unwanted files from the final build
You need to remove node_module, vendor, .git, etc from the final build. Github action also can take care of it.

Create a .distignore file on the plugin root folder and add files-folders that you don’t want to add in your final build for deployment. Basically, Github will use ‘WP-CLI’ and a third-party tool ‘Dist Archive’ to remove those files and folders, and then it will create a zip.


That’s it, you are done. Now whenever we create or push a git tag on GitHub, this action will run automatically and the plugin will be deployed on the WordPress ORG plugin repository.

0 0 votes
Article Rating