Introducing GitHub Actions for WordPress (Plugins)

Do you develop your WordPress plugins on GitHub? Then here’s a treat for you! We’re excited to release a GitHub Action that deploys to the WordPress.org Plugin Repository whenever you tag a new version on GitHub. You’ll be able to manage your entire development lifecycle in GitHub—no more futzing with local Bash scripts or controlling commit/push access in multiple places.

Keep reading for more details about GitHub Actions and how to get set up, but the gist is this: you reference our action in your plugin repo’s workflow file, filtered to only run when a tag is pushed, and set your username/password secrets. After that, each time you tag a new version on GitHub, whether by pushing a Git tag from the command line or making one using the GitHub releases interface, your plugin will be deployed to WordPress.org.

What’s a GitHub Action?

GitHub Actions, announced at GitHub Universe 2018, is a way to automate development workflows using container-based actions. And since they’re on GitHub, they’re shareable and customizable across the open source ecosystem. Workflows can be triggered by GitHub platform events (e.g. push, issue opened, release published), can run a sequence of actions in response, can be written in any language, and can interact with the full GitHub API and any other public API.

If you’re interested in learning more and building your own GitHub Actions, then check out GitHub’s documentation, their pre-built actions, and sign up for the limited public beta of GitHub Actions. For an even more in-depth walkthrough of creating your own GitHub Action, there’s an excellent writeup on CSS-Tricks and an insider’s perspective from Jessie Frazelle.

Let’s do this!

To get started, head to the Actions tab in your Actions-enabled GitHub repo and create a new workflow. You can use the visual editor, or copy and paste the example from our Action’s readme. You will then want to set the SVN_PASSWORD and SVN_USERNAME secrets, either in the Action visual editor or in the repository settings. Don’t worry though, these secrets cannot be viewed as plaintext again once you’ve saved them, so you can use your WordPress.org SVN credentials without exposing them to other contributors.

Once that’s all set, every time you push a new tag to GitHub or create one using GitHub’s releases feature, a new version will be deployed to your WordPress.org repository. By default, it will attempt to deploy to a repository with the same slug as your GitHub repo, but this can be customized using the SLUG environment variable. The deployment does the following:

  • Copies WordPress.org-specific assets to the top-level assets directory in SVN (by default it looks for a .wordpress-org subfolder but this can be customized using the ASSETS_DIR variable)
  • Commits all other new, modified, and deleted files to trunk
  • Copies the contents of trunk to tags/VERSION, where VERSION is the name of your tag in Git

This Action is ready to use today for those already in the GitHub Actions beta (request beta access). Note that public repositories are currently only able to trigger Actions on push. Instructions and examples including information about customizations can be found in the readme file. We are also working on more Actions to release soon. Happy plugin deploying!

Want to build amazing websites and tools like this that help web engineers? Do you love being a part of the open-source community? Join our team and help us make the web a better place.

Comments

  1. Really great! Good starting point to figure out how actions work. How do you handle keeping the svn pass secret? That seems a bit of a leap of faith to me.

  2. Hi Helen,

    I’m glad that you shared this, it’s amazing, I will love to not deal with TortoiseSVN anymore :P
    Just one question, how can we tell the action to ignore some file or folders? (Like package.json, for example)

    Thanks!

    • I would suggest using a gitattributes file. Take a look at one in my projects: https://github.com/thefrosty/wp-utilities/blob/master/.gitattributes

      You can set what you want to ignore on release/tag creation.

      • Thanks TheFrosty! I used .gitattributes one time, but never understood completely your usage and application, now it make’s more sense to me!

  3. Wow! No more scripts to publish to WP plugin repo then.

  4. Much appreciated :) We are planning to push our plugins on GitHub now.
    Its very time saving & escape us from managing the plugins manually.
    Thank you 10up team :)

  5. Does this need to be a private repo on Git? If not, can someone view the keys inside of the .sh file?

  6. Fantastic tool you have created, just tested it for the first time today. How can I exclude my github README.md from the wordpress repo?

    I added the file to .distignore but it still gets added to the WordPress repo. Not a big issue but I would like to exclude it if possible.

Leave a Comment

Let’s work together.

Connect with us to discuss your next project.