{"id":2974,"date":"2021-06-06T16:50:58","date_gmt":"2021-06-06T14:50:58","guid":{"rendered":"https:\/\/davidperezgar.com\/?p=2974"},"modified":"2024-08-21T11:20:19","modified_gmt":"2024-08-21T09:20:19","slug":"public-plugin-wordpress-from-github","status":"publish","type":"post","link":"https:\/\/davidperezgar.com\/en\/blog\/web-development\/public-plugin-wordpress-from-github\/","title":{"rendered":"Publish\/update a WordPress SVN plugin directly from GitHub"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">I learned this recently thanks to <a href=\"https:\/\/www.twitch.tv\/videos\/986101570?t=00h24m01s\" target=\"_blank\" rel=\"noopener\">Fran Torres<\/a>&#8216;s live <a href=\"https:\/\/www.twitch.tv\/videos\/986101570?t=00h24m01s\" target=\"_blank\" rel=\"noopener\">Fran Torres<\/a> explaining of how to publish directly to WordPress SVN.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-wordpress-tv-embed wp-block-embed-wordpress-tv-embed wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"VideoPress Video Player\" aria-label='VideoPress Video Player' width='1200' height='675' src='https:\/\/video.wordpress.com\/embed\/DPpjABXM?hd=1&amp;cover=1' frameborder='0' allowfullscreen allow='clipboard-write'><\/iframe><script src='https:\/\/v0.wordpress.com\/js\/next\/videopress-iframe.js?m=1674852142'><\/script>\n<\/div><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-svn\">What is SVN?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">SVN is short for Subversion, and is the version control for WordPress repositories such as the core itself, and also plugins. Once we&#8217;ve submitted the <a href=\"https:\/\/es.wordpress.org\/plugins\/developers\/add\/\" target=\"_blank\" rel=\"noopener\">WordPress plugin<\/a> and passed its review process, we can publish.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Without knowing much about it and what I&#8217;ve worked with, it&#8217;s very tedious, since every time you delete a directory, you can end up breaking the project version control. I&#8217;ve never been clear on it myself.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">But working with GitHub is wonderful, because thanks to the branches, we can break down our development in a very easy way.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Well, to connect GitHub with the SVN repository, we can use the GitHub Actions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"github-actions\">GitHub Actions<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">GitHub Actions <a href=\"https:\/\/github.com\/features\/actions\" target=\"_blank\" rel=\"noopener\">as their page explains<\/a>, are intended to automate processes within the production release of a software code.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Workflows can be executed in any GitHub event. In this case we will use <strong>the tag creation event.<\/strong> And every time we publish a new release on GitHub, it creates that tag and executes the code that sends the files to SVN.<\/p>\n\n\n\n<p class=\"has-green-background-color has-text-color has-background wp-block-paragraph\" style=\"color:#ffffffff\"><strong>Our workflow will be to create a release every time we want to publish to WordPress. <\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"config-github-actions-for-publishing-in-wordpress\">Configuring GitHub Actions for publishing to WordPress<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"724\" height=\"401\" src=\"https:\/\/davidperezgar.com\/wp-content\/uploads\/github-actions-wordpress-svn.png\" alt=\"github actions wordpress svn\" class=\"wp-image-2975\" title=\"\" srcset=\"https:\/\/davidperezgar.com\/en\/wp-content\/uploads\/sites\/4\/github-actions-wordpress-svn.png 724w, https:\/\/davidperezgar.com\/en\/wp-content\/uploads\/sites\/4\/github-actions-wordpress-svn-362x200.png 362w, https:\/\/davidperezgar.com\/en\/wp-content\/uploads\/sites\/4\/github-actions-wordpress-svn-596x330.png 596w\" sizes=\"auto, (max-width: 724px) 100vw, 724px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The action you can see it in its <a href=\"https:\/\/github.com\/marketplace\/actions\/wordpress-plugin-svn-deploy\" target=\"_blank\" rel=\"noopener\">GitHub action page<\/a>, where all the documentation to set it up comes. Next, I&#8217;ll show you my ideal setup.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the source of the repository in the main branch, we create a YML file with the following path:<\/p>\n\n\n\n<div class=\"cbc-code-wrapper\"><div class=\"cbc-code-bar\"><button class=\"cbc-copy-button\">Copy<\/button><\/div><pre class=\"wp-block-code\"><code class=\"\">.github\/workflows\/deploy.yml<\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">And with the following content:<\/p>\n\n\n\n<div class=\"cbc-code-wrapper\"><div class=\"cbc-code-bar\"><button class=\"cbc-copy-button\">Copy<\/button><\/div><pre class=\"wp-block-code\"><code class=\"\">name: Deploy to WordPress.org\non:\n  push:\n    tags:\n    - \"*\"\njobs:\n  tag:\n    name: New tag\n    runs-on: ubuntu-latest\n    steps:\n    - uses: actions\/checkout@master\n    - name: WordPress Plugin Deploy\n      uses: 10up\/action-wordpress-plugin-deploy@stable\n      env:\n        SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}\n        SVN_USERNAME: ${{ secrets.SVN_USERNAME }}<\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Note that this code assumes that your plugin&#8217;s SLUG is the same as the GitHub repository. Which on the other hand, I think is the most appropriate thing to do.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We will need to go to the repository menu to set up our SVN user and password. This is in: Settings &gt; Secrets and add SVN_USERNAME and its value, and SVN_PASSWORD and its value as well.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And then so that we can upload all the files related to the WordPress directory, we will need to create a folder:<\/p>\n\n\n\n<div class=\"cbc-code-wrapper\"><div class=\"cbc-code-bar\"><button class=\"cbc-copy-button\">Copy<\/button><\/div><pre class=\"wp-block-code\"><code class=\"\">\/.wordpress-org<\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">With the files we want to share, the plugin images and its resources as screenshots. This is:<\/p>\n\n\n\n<div class=\"cbc-code-wrapper\"><div class=\"cbc-code-bar\"><button class=\"cbc-copy-button\">Copy<\/button><\/div><pre class=\"wp-block-code\"><code class=\"\">banner-1544x500.png\nbanner-772x250.png\nicon-128x128.png\nicon-256x256.png\nscreenshot-1.png\nscreenshot-2.png<\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">SVG or JPG format can also be used for icons.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So now we would have everything set up. Now every time we <strong>create a release<\/strong>, it will run our action and publish to WordPress.org. In the Actions tab, you can see the log of each execution. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1160\" height=\"775\" src=\"https:\/\/davidperezgar.com\/wp-content\/uploads\/github-actions-ejemplos.png\" alt=\"github actions examples\" class=\"wp-image-2977\" title=\"\" srcset=\"https:\/\/davidperezgar.com\/en\/wp-content\/uploads\/sites\/4\/github-actions-ejemplos.png 1160w, https:\/\/davidperezgar.com\/en\/wp-content\/uploads\/sites\/4\/github-actions-ejemplos-596x398.png 596w, https:\/\/davidperezgar.com\/en\/wp-content\/uploads\/sites\/4\/github-actions-ejemplos-768x513.png 768w, https:\/\/davidperezgar.com\/en\/wp-content\/uploads\/sites\/4\/github-actions-ejemplos-1082x723.png 1082w\" sizes=\"auto, (max-width: 1160px) 100vw, 1160px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Resources:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Plugin with published action: <a href=\"https:\/\/github.com\/closemarketing\/woocommerce-es\" target=\"_blank\" rel=\"noopener\">WooCommerce ES<\/a>.<\/li>\n\n\n\n<li><a href=\"tps:\/\/github.com\/marketplace\/actions\/wordpress-plugin-svn-deploy\" target=\"_blank\" rel=\"noopener\">10up action for publishing to WordPress SVN<\/a>.<\/li>\n\n\n\n<li><a href=\"https:\/\/developer.wordpress.org\/plugins\/wordpress-org\/plugin-assets\/\" target=\"_blank\" rel=\"noopener\">Image resources from the WordPress repository.<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>I learned this recently thanks to Fran Torres&#8217;s live video explaining how to publish directly to WordPress SVN. What is SVN? SVN stands for Subversion, and it is the version control for WordPress repositories such as the core itself, and also plugins. Once we have submitted the WordPress plugin and passed its review process, we can publish. Without knowing much about it and what I&#8217;ve worked with, it&#8217;s very tedious, since every time you delete a directory, you can end up breaking the project version control. I have never been able to clarify it myself. In [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":4149,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","inline_featured_image":false,"_ayudawp_aiss_exclude":false,"webmentions_disabled_pings":false,"webmentions_disabled":false,"editor_notices":[],"footnotes":""},"categories":[168],"tags":[551,552],"class_list":["post-2974","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web-development","tag-github","tag-wordpress","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50"],"_links":{"self":[{"href":"https:\/\/davidperezgar.com\/en\/wp-json\/wp\/v2\/posts\/2974","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/davidperezgar.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/davidperezgar.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/davidperezgar.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/davidperezgar.com\/en\/wp-json\/wp\/v2\/comments?post=2974"}],"version-history":[{"count":0,"href":"https:\/\/davidperezgar.com\/en\/wp-json\/wp\/v2\/posts\/2974\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/davidperezgar.com\/en\/wp-json\/wp\/v2\/media\/4149"}],"wp:attachment":[{"href":"https:\/\/davidperezgar.com\/en\/wp-json\/wp\/v2\/media?parent=2974"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/davidperezgar.com\/en\/wp-json\/wp\/v2\/categories?post=2974"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/davidperezgar.com\/en\/wp-json\/wp\/v2\/tags?post=2974"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}