{"id":5398,"date":"2023-06-08T03:35:00","date_gmt":"2023-06-08T08:35:00","guid":{"rendered":"https:\/\/wpengine.com\/builders\/?p=5398"},"modified":"2023-06-29T13:36:49","modified_gmt":"2023-06-29T18:36:49","slug":"github-actions-for-deployments","status":"publish","type":"post","link":"https:\/\/wpengine.com\/builders\/github-actions-for-deployments\/","title":{"rendered":"GitHub Actions for Deployments"},"content":{"rendered":"\n<p>Having an established end-to-end workflow for your site development process with Git version control can allow you to onboard a new developer quickly, keep a history of changes and elevate the consistency and quality of products for clients. Build quickly with Local, stage and keep a history with Git and GitHub Actions, promote to the production website when ready, and continue the process by maintaining an up-to-date local environment with Local Connect.<\/p>\n\n\n\n<div class=\"wp-block-group has-polar-background-color has-background has-global-padding is-layout-constrained wp-container-core-group-is-layout-8c185ad2 wp-block-group-is-layout-constrained\" style=\"border-radius:8px;padding-top:var(--wp--preset--spacing--30);padding-right:var(--wp--preset--spacing--40);padding-bottom:10px;padding-left:var(--wp--preset--spacing--40)\">\n<p class=\"has-small-font-size\"><em>This post is part of a series that helps set up an end-to-end workflow for developing sites.<\/em><\/p>\n\n\n\n<ul class=\"wp-block-list\" style=\"margin-top:12px;margin-right:var(--wp--preset--spacing--30);margin-bottom:var(--wp--preset--spacing--30);margin-left:var(--wp--preset--spacing--30)\">\n<li>Part One: <a href=\"https:\/\/wpengine.com\/builders\/local-wordpress-development-site\/\">Set Up a Local WordPress Development Site<\/a><\/li>\n\n\n\n<li>Part Two: <a href=\"https:\/\/wpengine.com\/builders\/git-version-control-in-local\/\">Git Version Control (in Local)<\/a><\/li>\n\n\n\n<li>Part Three: <strong>GitHub Actions for Deployments<\/strong><\/li>\n\n\n\n<li>Part Four: <a href=\"https:\/\/wpengine.com\/builders\/synchronize-production-data-with-local-connect\/\">S<\/a><a href=\"https:\/\/wpengine.com\/builders\/synchronize-production-data\/\">ynchronize Production Data With Local Connect<\/a><\/li>\n<\/ul>\n<\/div>\n\n\n\n<p>In the previous post in this series, we initialized our Git repo, told Git what we wanted to track (and ignore), and published our code and history to GitHub. Next, let&#8217;s set up some GitHub Actions within our repository to trigger deployments to our WP Engine environments. Here are the key steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Add the&nbsp;<strong>Deploy WordPress to WP Engine GitHub Actions<\/strong>&nbsp;to your repository, and<\/li>\n\n\n\n<li>Generate an SSH key: public key will go into the WP Engine SSH Gateway and assign the private key to your GitHub repo. This will allow the GitHub Action to access the appropriate WP Engine environment securely.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"add-github-actions\">Add the WP Engine GitHub Actions for deployments<\/h3>\n\n\n\n<p>We will use the&nbsp;<a href=\"https:\/\/github.com\/marketplace\/actions\/deploy-wordpress-to-wp-engine\" target=\"_blank\" rel=\"noreferrer noopener\">Deploy WordPress to WP Engine<\/a>&nbsp;GitHub Action to add a few YAML-language files (.yml) to our Git repo. Each YAML file will represent the configuration for a corresponding branch from which we want to trigger deployment and the targeted WP Engine environment. Here is what we&#8217;re going for:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Branch name<\/th><th>GitHub Action YAML filename<\/th><th>WP Engine environment<\/th><\/tr><\/thead><tbody><tr><td><code>main<\/code><\/td><td><code>.github\/workflows\/main.yml<\/code> (<a href=\"https:\/\/gist.github.com\/colorful-tones\/bad9c34440dab1f37f0f90122fc04184#file-main-yml\">full source<\/a>)<\/td><td>Production<\/td><\/tr><tr><td><code>stage<\/code><\/td><td><code>.github\/workflows\/stage.yml<\/code> (<a href=\"https:\/\/gist.github.com\/colorful-tones\/bad9c34440dab1f37f0f90122fc04184#file-stage-yml\">full source<\/a>)<\/td><td>Staging<\/td><\/tr><tr><td><code>dev<\/code><\/td><td><code>.github\/workflows\/dev.yml<\/code> (<a href=\"https:\/\/gist.github.com\/colorful-tones\/bad9c34440dab1f37f0f90122fc04184#file-dev-yml\">full source<\/a>)<\/td><td>Development<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>We want the Staging and Development environments and their corresponding branches to represent our in-flight development work. In contrast, the <code>main<\/code> branch remains our pristine Git history and codebase.<\/p>\n\n\n\n<p>This branching convention is a typical workflow, a hybrid model of&nbsp;<a href=\"https:\/\/nvie.com\/posts\/a-successful-git-branching-model\/\" target=\"_blank\" rel=\"noreferrer noopener\">git-flow<\/a>&nbsp;(over ten years old!) and&nbsp;<a href=\"https:\/\/docs.github.com\/en\/get-started\/quickstart\/github-flow\" target=\"_blank\" rel=\"noreferrer noopener\">GitHub Flow<\/a>. It enables you and any code collaborators to work simultaneously on other features or hotfixes simultaneously while continuously deploying.<\/p>\n\n\n\n<p>If a new feature or discrete set of code changes are needed, we&#8217;ll branch off the <code>main<\/code> branch and create a new branch, for example, <code>feature\/new-header<\/code>. We&#8217;ll work within our Local WordPress development environment to add the new header code, commit our changes, publish the <code>feature\/new-header<\/code> branch to GitHub (for pull requests, remote collaboration, history, and backup), then merge the <code>feature\/new-header<\/code> branch into the <code>stage<\/code> (or <code>dev<\/code> depending on how you prefer to work), and push the latest copy of the <code>stage<\/code> branch up to GitHub, which would trigger our GitHub Action to deploy GitHub&#8217;s <code>stage<\/code> branch to the WP Engine Staging environment. Then allow the client to review the work on the staging site.<\/p>\n\n\n\n<p>This entire end-to-end process should be more evident by the end of this series when we take you through the whole cycle.<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<div class=\"wp-block-group has-polar-background-color has-background is-nowrap is-layout-flex wp-container-core-group-is-layout-85b72d78 wp-block-group-is-layout-flex\" style=\"border-radius:8px;padding-top:0;padding-right:0;padding-bottom:0;padding-left:0\">\n<div class=\"wp-block-group has-base-color has-lapis-background-color has-text-color has-background is-horizontal is-nowrap is-layout-flex wp-container-core-group-is-layout-adf5909b wp-block-group-is-layout-flex\" style=\"border-top-left-radius:8px;border-top-right-radius:0px;border-bottom-left-radius:8px;border-bottom-right-radius:0px;padding-top:18px;padding-right:18px;padding-bottom:18px;padding-left:18px\">\n<div class=\"wp-block-outermost-icon-block\"><div class=\"icon-container has-icon-color has-polar-color\" style=\"color:#f4f7fa;width:24px\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"-2 -2 24 24\" aria-hidden=\"true\"><path d=\"M10 2c4.42 0 8 3.58 8 8s-3.58 8-8 8-8-3.58-8-8 3.58-8 8-8zm1.13 9.38l.35-6.46H8.52l.35 6.46h2.26zm-.09 3.36c.24-.23.37-.55.37-.96 0-.42-.12-.74-.36-.97s-.59-.35-1.06-.35-.82.12-1.07.35-.37.55-.37.97c0 .41.13.73.38.96.26.23.61.34 1.06.34s.8-.11 1.05-.34z\"><\/path><\/svg><\/div><\/div>\n\n\n\n<p class=\"has-medium-large-font-size\"><strong><em>Tip<\/em><\/strong><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-small-font-size wp-container-content-ceb7f5b3 is-vertical is-layout-flex wp-container-core-group-is-layout-d60103d6 wp-block-group-is-layout-flex\" style=\"padding-top:18px;padding-right:18px;padding-bottom:18px;padding-left:18px\">\n<p><strong>Dig in and learn!<\/strong><\/p>\n\n\n\n<p>WP Engine GitHub Actions utilize rsync to deploy code. By default, rsync runs in non-destructive mode, but you can override this behavior by passing additional <code>FLAGS<\/code>. Please <a href=\"https:\/\/github.com\/marketplace\/actions\/deploy-wordpress-to-wp-engine#deploy-options\">visit the complete documentation<\/a> to learn about all the options available, like running post-deploy scripts, linting PHP, and busting your environment&#8217;s cache.<\/p>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<p>For now, create and save two (or three if you want to set up the Development environment as well, but optional) new files within your Git repo, commit the changes, and push them up on the <code>main<\/code> branch. At the very least, we&#8217;ll want <code>.github\/workflows\/main.yml<\/code> and <code>.github\/workflows\/stage.yml<\/code> files within our <code>wp-content\/<\/code> directory with the following configuration code:<\/p>\n\n\n\n<div class=\"wp-block-group is-style-boxshadow has-polar-background-color has-background has-global-padding is-layout-constrained wp-container-core-group-is-layout-254f1302 wp-block-group-is-layout-constrained\" style=\"padding-top:0;padding-right:0;padding-bottom:0;padding-left:0\">\n<p class=\"has-text-align-center has-polar-background-color has-background has-small-font-size\" style=\"margin-top:0;margin-right:0;margin-bottom:0;margin-left:0;padding-top:0;padding-right:0;padding-bottom:0;padding-left:0\"><code>stage.yml<\/code> (<a href=\"https:\/\/gist.github.com\/colorful-tones\/9adeab19373a0b3693795f199b188c8c\" target=\"_blank\" rel=\"noreferrer noopener\">full sourc<\/a><a href=\"https:\/\/gist.github.com\/colorful-tones\/9adeab19373a0b3693795f199b188c8c\">e<\/a>)<\/p>\n\n\n<pre class=\"wp-block-code\" style=\"margin-top:0;margin-bottom:0\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-code-table shcb-line-numbers\"><span class='shcb-loc'><span>name: Deploy to a WP Engine Staging environment\n<\/span><\/span><span class='shcb-loc'><span><span class=\"hljs-attr\">on<\/span>:\n<\/span><\/span><span class='shcb-loc'><span>  push:\n<\/span><\/span><span class='shcb-loc'><span>    branches:\n<\/span><\/span><mark class='shcb-loc'><span>     - stage\n<\/span><\/mark><span class='shcb-loc'><span><span class=\"hljs-attr\">jobs<\/span>:\n<\/span><\/span><span class='shcb-loc'><span>  build:\n<\/span><\/span><span class='shcb-loc'><span>    runs-on: ubuntu-latest\n<\/span><\/span><span class='shcb-loc'><span>    <span class=\"hljs-attr\">steps<\/span>:\n<\/span><\/span><span class='shcb-loc'><span>    - uses: actions\/checkout@v3\n<\/span><\/span><span class='shcb-loc'><span>    - name: GitHub Action Deploy to WP Engine\n<\/span><\/span><span class='shcb-loc'><span>      <span class=\"hljs-attr\">uses<\/span>: wpengine\/github-action-wpe-site-deploy@v3\n<\/span><\/span><span class='shcb-loc'><span>      <span class=\"hljs-attr\">with<\/span>:\n<\/span><\/span><mark class='shcb-loc'><span>        REMOTE_PATH: <span class=\"hljs-string\">\"wp-content\/\"<\/span>\n<\/span><\/mark><mark class='shcb-loc'><span>        <span class=\"hljs-attr\">WPE_SSHG_KEY_PRIVATE<\/span>: ${{ secrets.WPE_SSHG_KEY_PRIVATE }}\n<\/span><\/mark><mark class='shcb-loc'><span>        <span class=\"hljs-attr\">WPE_ENV<\/span>: <span class=\"xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">your_install_name_here<\/span>&gt;<\/span><\/span>\n<\/span><\/mark><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre><\/div>\n\n\n\n<p><strong>Pay close attention to the following arguments in the above code and replace them with the necessary variables:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Branch name (highlighted on line 5) \u2013 the branch name that will trigger the deployment to the targeted environment upon push.<\/li>\n\n\n\n<li><code>REMOTE_PATH<\/code> (highlighted line 14) should point to the final environment&#8217;s targeted location.<\/li>\n\n\n\n<li><code>WPE_SSHG_KEY_PRIVATE<\/code> (highlighted line 15) will reference the private SSH key that we assign to our repository.<\/li>\n\n\n\n<li><code>WPE_ENV<\/code> (highlighted line 16) should represent the WP Engine targeted environment name, which you can find in your WP Engine Portal&#8217;s <a href=\"https:\/\/my.wpengine.com\/sites\">&#8216;My Sites&#8217; area<\/a>.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/wpengine.com\/builders\/wp-content\/uploads\/2023\/06\/WPE-my-sites.png\" alt=\"Screenshot of the WP Engine Portal My Sites area with environment name highlighted\" class=\"wp-image-5348\" srcset=\"https:\/\/wpengine.com\/builders\/wp-content\/uploads\/2023\/06\/WPE-my-sites.png 1200w, https:\/\/wpengine.com\/builders\/wp-content\/uploads\/2023\/06\/WPE-my-sites-300x169.png 300w, https:\/\/wpengine.com\/builders\/wp-content\/uploads\/2023\/06\/WPE-my-sites-1024x576.png 1024w, https:\/\/wpengine.com\/builders\/wp-content\/uploads\/2023\/06\/WPE-my-sites-768x432.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><figcaption class=\"wp-element-caption\">Screenshot of the WP Engine Portal My Sites area with environment name highlighted<\/figcaption><\/figure>\n\n\n\n<p>Don&#8217;t worry. Suppose you commit and push the new GitHub Actions. In that case, they will not successfully trigger anything yet, because we need to add our SSH keys for GitHub to deploy to WP Engine. That&#8217;s next.<\/p>\n\n\n\n<figure class=\"wp-block-image alignwide size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1280\" height=\"720\" src=\"https:\/\/wpengine.com\/builders\/wp-content\/uploads\/2023\/06\/Add-GitHub-Actions.gif\" alt=\"Demonstrating how to commit WPE GitHub Actions and pushing to GitHub\" class=\"wp-image-5344\"\/><figcaption class=\"wp-element-caption\">Demonstrating how to commit WPE GitHub Actions and pushing to GitHub<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"generate-ssh-keys\">Generate SSH keys for deployments<\/h3>\n\n\n\n<p>Whether you already have an SSH key in WP Engine&#8217;s Portal, I recommend creating a unique key for your deployments, which enables you to swap it out and only affects the deployment process.<\/p>\n\n\n\n<p>Open up the command-line interface of your choice (Terminal, iTerm) and run the following commands:<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-container-core-group-is-layout-19e250f3 wp-block-group-is-layout-constrained\">\n<p class=\"has-text-align-center has-polar-background-color has-background has-small-font-size\" style=\"padding-top:4px;padding-right:4px;padding-bottom:4px;padding-left:4px\">Generate a new SSH key. <em>Be sure to replace the last bit with your own file name.<\/em><br>Hit&nbsp;<em>enter<\/em>&nbsp;or&nbsp;<em>return<\/em>&nbsp;to <strong>leave the passphrase blank<\/strong>.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-code-table shcb-line-numbers\"><span class='shcb-loc'><span>ssh-keygen -t ed25519 -f ~<span class=\"hljs-regexp\">\/.ssh\/<\/span>wpe_gha_wpebuilders\n<\/span><\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre><\/div>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"add-public-key-to-wpengine\">Add public SSH key to WP Engine portal<\/h4>\n\n\n\n<p>We must add your newly generated SSH key to the WP Engine user portal. <\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Visit the User <strong>Portal &gt; Profile &gt; <a href=\"https:\/\/my.wpengine.com\/profile\/ssh_keys\" target=\"_blank\" rel=\"noreferrer noopener\">SSH Keys area<\/a><\/strong><\/li>\n\n\n\n<li>Click the &#8216;Create SSH key&#8217; button (top, right side)<\/li>\n\n\n\n<li>We&#8217;ll need to copy your newly created SSH key&#8217;s <strong>public<\/strong> file. Open your command line tool and run the following command to copy the public key to your clipboard: <code>cat ~\/.ssh\/wpe_gha_wpebuilders.pub | pbcopy<\/code> (Be sure to replace the last bit with <em>your<\/em> file name)<\/li>\n\n\n\n<li>Paste the public key into the &#8216;New SSH key&#8217; modal and click the &#8216;Add SSH key&#8217; button<\/li>\n<\/ol>\n\n\n\n<p>You should now see your SSH key among the &#8216;My SSH keys.&#8217;<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"add-private-key-to-github\">Add private SSH key to GitHub<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Go to your GitHub repo&#8217;s <strong>Settings<\/strong> tab &gt; <strong>Secrets<\/strong> &gt; <strong>Actions<\/strong><\/li>\n\n\n\n<li>Click the &#8216;New repository secret&#8217; button (top, right side)<\/li>\n\n\n\n<li>We must copy your newly created SSH key&#8217;s <strong>private<\/strong> file contents. Open your command line tool, and run the following command to copy the private key to your clipboard: <code>cat ~\/.ssh\/wpe_gha_wpebuilders | pbcopy<\/code> (Be sure to replace the last bit with <em>your<\/em> file name)<\/li>\n\n\n\n<li>Paste the private key into the &#8216;Secret&#8217; field and the &#8216;Name&#8217; field should be: <code>WPE_SSHG_KEY_PRIVATE<\/code>, and click the &#8216;Add secret&#8217; to save.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image alignwide size-full has-custom-border is-style-border\"><img loading=\"lazy\" decoding=\"async\" width=\"1920\" height=\"1080\" src=\"https:\/\/wpengine.com\/builders\/wp-content\/uploads\/2023\/06\/add-ssh-key-github-repo.png\" alt=\"Screenshot of GitHub repo's Settings &gt; Actions Secrets screen\" class=\"has-border-color has-polar-border-color wp-image-5366\" srcset=\"https:\/\/wpengine.com\/builders\/wp-content\/uploads\/2023\/06\/add-ssh-key-github-repo.png 1920w, https:\/\/wpengine.com\/builders\/wp-content\/uploads\/2023\/06\/add-ssh-key-github-repo-300x169.png 300w, https:\/\/wpengine.com\/builders\/wp-content\/uploads\/2023\/06\/add-ssh-key-github-repo-1024x576.png 1024w, https:\/\/wpengine.com\/builders\/wp-content\/uploads\/2023\/06\/add-ssh-key-github-repo-768x432.png 768w, https:\/\/wpengine.com\/builders\/wp-content\/uploads\/2023\/06\/add-ssh-key-github-repo-1536x864.png 1536w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><figcaption class=\"wp-element-caption\">Screenshot of GitHub repo&#8217;s Settings &gt; Actions Secrets screen<\/figcaption><\/figure>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<div class=\"wp-block-group has-polar-background-color has-background is-nowrap is-layout-flex wp-container-core-group-is-layout-85b72d78 wp-block-group-is-layout-flex\" style=\"border-radius:8px;padding-top:0;padding-right:0;padding-bottom:0;padding-left:0\">\n<div class=\"wp-block-group has-base-color has-lapis-background-color has-text-color has-background is-horizontal is-nowrap is-layout-flex wp-container-core-group-is-layout-adf5909b wp-block-group-is-layout-flex\" style=\"border-top-left-radius:8px;border-bottom-left-radius:8px;padding-top:18px;padding-right:18px;padding-bottom:18px;padding-left:18px\">\n<div class=\"wp-block-outermost-icon-block\"><div class=\"icon-container has-icon-color has-polar-color\" style=\"color:#f4f7fa;width:24px\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"-2 -2 24 24\" aria-hidden=\"true\"><path d=\"M10 2c4.42 0 8 3.58 8 8s-3.58 8-8 8-8-3.58-8-8 3.58-8 8-8zm1.13 9.38l.35-6.46H8.52l.35 6.46h2.26zm-.09 3.36c.24-.23.37-.55.37-.96 0-.42-.12-.74-.36-.97s-.59-.35-1.06-.35-.82.12-1.07.35-.37.55-.37.97c0 .41.13.73.38.96.26.23.61.34 1.06.34s.8-.11 1.05-.34z\"><\/path><\/svg><\/div><\/div>\n\n\n\n<p class=\"has-medium-large-font-size\"><strong><em>Tip<\/em><\/strong><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-small-font-size wp-container-content-ceb7f5b3 is-vertical is-layout-flex wp-container-core-group-is-layout-d60103d6 wp-block-group-is-layout-flex\" style=\"padding-top:18px;padding-right:18px;padding-bottom:18px;padding-left:18px\">\n<p><strong>Consider using a GitHub Organization<\/strong><\/p>\n\n\n\n<p>If you plan to use GitHub to host your repositories solely and expect to collaborate with various developers (in-house and freelance). Consider setting up a&nbsp;<a href=\"https:\/\/docs.github.com\/en\/organizations\/collaborating-with-groups-in-organizations\/about-organizations\" target=\"_blank\" rel=\"noreferrer noopener\">GitHub Organization<\/a>, allowing you to&nbsp;<a href=\"https:\/\/docs.github.com\/en\/actions\/security-guides\/encrypted-secrets#creating-encrypted-secrets-for-an-organization\" target=\"_blank\" rel=\"noreferrer noopener\">share an organization-level secret<\/a>&nbsp;across different GitHub repos like your deploy SSH key.<\/p>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Test it out<\/h2>\n\n\n\n<p>We&#8217;ve added our GitHub Actions to our repository and generated and assigned our SSH keys. Now, you should be able to trigger a successful deployment by either:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Go to your GitHub repository&#8217;s Actions tab and trigger an Action, or<\/li>\n\n\n\n<li>Push up some code on one of the branches to trigger a new deployment.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">What&#8217;s next?<\/h2>\n\n\n\n<p>We should have targeted branch-to-environment deployments successfully set up. This will allow us to specify whether we want certain developers to have access to merge into our <code>dev<\/code>, <code>stage<\/code>, or <code>main<\/code> branches, which can all be controlled through our GitHub user settings. <\/p>\n\n\n\n<p>Perhaps Senior Engineers should have permission to merge branches into the <code>main<\/code> branch, but Junior Engineers would only be allowed to open Pull Requests against <code>main<\/code>, but not merge. How you manage these permissions are entirely up to how you want to facilitate your workflow, and GitHub offers a lot of flexibility.<\/p>\n\n\n\n<p>Next, we&#8217;ll want to ensure that our developers have access to the latest production data, and we can easily leverage Local&#8217;s Connect to do it.<\/p>\n\n\n\n<div class=\"wp-block-group has-base-color has-lapis-background-color has-text-color has-background has-link-color wp-elements-52272821dc07b42e9e0a5fa2d5b8b87e is-nowrap is-layout-flex wp-container-core-group-is-layout-89a94f6a wp-block-group-is-layout-flex\" style=\"border-radius:8px\">\n<p class=\"has-medium-large-font-size\"><a href=\"https:\/\/wpengine.com\/builders\/synchronize-production-data-with-local-connect\/\"><strong>Next up: Synchronize Production Data With Local Connect<\/strong><\/a><\/p>\n\n\n\n<div class=\"wp-block-outermost-icon-block\"><a class=\"icon-container has-icon-color has-base-color\" href=\"https:\/\/wpengine.com\/builders\/synchronize-production-data-with-local-connect\/\" style=\"color:#fff;width:26px\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z\"><\/path><\/svg><\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Get started with GitHub Actions and use them to trigger deployments to WP Engine environments.<\/p>\n","protected":false},"author":11,"featured_media":5309,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_EventAllDay":false,"_EventTimezone":"","_EventStartDate":"","_EventEndDate":"","_EventStartDateUTC":"","_EventEndDateUTC":"","_EventShowMap":false,"_EventShowMapLink":false,"_EventURL":"","_EventCost":"","_EventCostDescription":"","_EventCurrencySymbol":"","_EventCurrencyCode":"","_EventCurrencyPosition":"","_EventDateTimeSeparator":"","_EventTimeRangeSeparator":"","_EventOrganizerID":[],"_EventVenueID":[],"_OrganizerEmail":"","_OrganizerPhone":"","_OrganizerWebsite":"","_VenueAddress":"","_VenueCity":"","_VenueCountry":"","_VenueProvince":"","_VenueState":"","_VenueZip":"","_VenuePhone":"","_VenueURL":"","_VenueStateProvince":"","_VenueLat":"","_VenueLng":"","_VenueShowMap":false,"_VenueShowMapLink":false,"footnotes":""},"categories":[1],"tags":[11,14,35],"class_list":["post-5398","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress","tag-github","tag-github-action","tag-workflow"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>GitHub Actions for Deployments - Builders<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/wpengine.com\/builders\/github-actions-for-deployments\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"GitHub Actions for Deployments - Builders\" \/>\n<meta property=\"og:description\" content=\"Get started with GitHub Actions and use them to trigger deployments to WP Engine environments.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/wpengine.com\/builders\/github-actions-for-deployments\/\" \/>\n<meta property=\"og:site_name\" content=\"Builders\" \/>\n<meta property=\"article:published_time\" content=\"2023-06-08T08:35:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-06-29T18:36:49+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/wpengine.com\/builders\/wp-content\/uploads\/2023\/06\/github-actions-for-deployments.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Damon Cook\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/wpengine.com\/builders\/wp-content\/uploads\/2023\/06\/github-actions-for-deployments.jpg\" \/>\n<meta name=\"twitter:creator\" content=\"@dcook\" \/>\n<meta name=\"twitter:site\" content=\"@wpebuilders\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Damon Cook\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/github-actions-for-deployments\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/github-actions-for-deployments\\\/\"},\"author\":{\"name\":\"Damon Cook\",\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/#\\\/schema\\\/person\\\/9d8d20c8a321b90faceae588fcf6d30d\"},\"headline\":\"GitHub Actions for Deployments\",\"datePublished\":\"2023-06-08T08:35:00+00:00\",\"dateModified\":\"2023-06-29T18:36:49+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/github-actions-for-deployments\\\/\"},\"wordCount\":1303,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/github-actions-for-deployments\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/Local-GitHub-workflow.png\",\"keywords\":[\"GitHub\",\"GitHub Action\",\"workflow\"],\"articleSection\":[\"WordPress\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/wpengine.com\\\/builders\\\/github-actions-for-deployments\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/github-actions-for-deployments\\\/\",\"url\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/github-actions-for-deployments\\\/\",\"name\":\"GitHub Actions for Deployments - Builders\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/github-actions-for-deployments\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/github-actions-for-deployments\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/Local-GitHub-workflow.png\",\"datePublished\":\"2023-06-08T08:35:00+00:00\",\"dateModified\":\"2023-06-29T18:36:49+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/github-actions-for-deployments\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/wpengine.com\\\/builders\\\/github-actions-for-deployments\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/github-actions-for-deployments\\\/#primaryimage\",\"url\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/Local-GitHub-workflow.png\",\"contentUrl\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/Local-GitHub-workflow.png\",\"width\":1920,\"height\":1080,\"caption\":\"diagram demonstrating a workflow for promoting code to production on WP Engine\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/github-actions-for-deployments\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"GitHub Actions for Deployments\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/#website\",\"url\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/\",\"name\":\"Builders\",\"description\":\"Reimagining the way we build with WordPress.\",\"publisher\":{\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/#organization\",\"name\":\"WP Engine\",\"url\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/wp-content\\\/uploads\\\/2024\\\/05\\\/WP-Engine-Horizontal@2x.png\",\"contentUrl\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/wp-content\\\/uploads\\\/2024\\\/05\\\/WP-Engine-Horizontal@2x.png\",\"width\":348,\"height\":68,\"caption\":\"WP Engine\"},\"image\":{\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/x.com\\\/wpebuilders\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCh1WuL54XFb9ZI6m6goFv1g\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/#\\\/schema\\\/person\\\/9d8d20c8a321b90faceae588fcf6d30d\",\"name\":\"Damon Cook\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/18d75285d6803fab88b7f45601bb68cbac7c3956347217c06a0291e27dc65f6a?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/18d75285d6803fab88b7f45601bb68cbac7c3956347217c06a0291e27dc65f6a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/18d75285d6803fab88b7f45601bb68cbac7c3956347217c06a0291e27dc65f6a?s=96&d=mm&r=g\",\"caption\":\"Damon Cook\"},\"description\":\"Damon Cook is a Developer Advocate at WP Engine. Previously, he navigated the WordPress agency land for a decade. He is a purveyor and discoverer of musical frisson. He can be found in the realms of WordPress Slack, WooCommerce Slack, and Twitter.\",\"sameAs\":[\"https:\\\/\\\/x.com\\\/dcook\"],\"url\":\"https:\\\/\\\/wpengine.com\\\/builders\\\/author\\\/damon-cook\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"GitHub Actions for Deployments - Builders","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/wpengine.com\/builders\/github-actions-for-deployments\/","og_locale":"en_US","og_type":"article","og_title":"GitHub Actions for Deployments - Builders","og_description":"Get started with GitHub Actions and use them to trigger deployments to WP Engine environments.","og_url":"https:\/\/wpengine.com\/builders\/github-actions-for-deployments\/","og_site_name":"Builders","article_published_time":"2023-06-08T08:35:00+00:00","article_modified_time":"2023-06-29T18:36:49+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/wpengine.com\/builders\/wp-content\/uploads\/2023\/06\/github-actions-for-deployments.jpg","type":"image\/jpeg"}],"author":"Damon Cook","twitter_card":"summary_large_image","twitter_image":"https:\/\/wpengine.com\/builders\/wp-content\/uploads\/2023\/06\/github-actions-for-deployments.jpg","twitter_creator":"@dcook","twitter_site":"@wpebuilders","twitter_misc":{"Written by":"Damon Cook","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/wpengine.com\/builders\/github-actions-for-deployments\/#article","isPartOf":{"@id":"https:\/\/wpengine.com\/builders\/github-actions-for-deployments\/"},"author":{"name":"Damon Cook","@id":"https:\/\/wpengine.com\/builders\/#\/schema\/person\/9d8d20c8a321b90faceae588fcf6d30d"},"headline":"GitHub Actions for Deployments","datePublished":"2023-06-08T08:35:00+00:00","dateModified":"2023-06-29T18:36:49+00:00","mainEntityOfPage":{"@id":"https:\/\/wpengine.com\/builders\/github-actions-for-deployments\/"},"wordCount":1303,"commentCount":0,"publisher":{"@id":"https:\/\/wpengine.com\/builders\/#organization"},"image":{"@id":"https:\/\/wpengine.com\/builders\/github-actions-for-deployments\/#primaryimage"},"thumbnailUrl":"https:\/\/wpengine.com\/builders\/wp-content\/uploads\/2023\/06\/Local-GitHub-workflow.png","keywords":["GitHub","GitHub Action","workflow"],"articleSection":["WordPress"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/wpengine.com\/builders\/github-actions-for-deployments\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/wpengine.com\/builders\/github-actions-for-deployments\/","url":"https:\/\/wpengine.com\/builders\/github-actions-for-deployments\/","name":"GitHub Actions for Deployments - Builders","isPartOf":{"@id":"https:\/\/wpengine.com\/builders\/#website"},"primaryImageOfPage":{"@id":"https:\/\/wpengine.com\/builders\/github-actions-for-deployments\/#primaryimage"},"image":{"@id":"https:\/\/wpengine.com\/builders\/github-actions-for-deployments\/#primaryimage"},"thumbnailUrl":"https:\/\/wpengine.com\/builders\/wp-content\/uploads\/2023\/06\/Local-GitHub-workflow.png","datePublished":"2023-06-08T08:35:00+00:00","dateModified":"2023-06-29T18:36:49+00:00","breadcrumb":{"@id":"https:\/\/wpengine.com\/builders\/github-actions-for-deployments\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/wpengine.com\/builders\/github-actions-for-deployments\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wpengine.com\/builders\/github-actions-for-deployments\/#primaryimage","url":"https:\/\/wpengine.com\/builders\/wp-content\/uploads\/2023\/06\/Local-GitHub-workflow.png","contentUrl":"https:\/\/wpengine.com\/builders\/wp-content\/uploads\/2023\/06\/Local-GitHub-workflow.png","width":1920,"height":1080,"caption":"diagram demonstrating a workflow for promoting code to production on WP Engine"},{"@type":"BreadcrumbList","@id":"https:\/\/wpengine.com\/builders\/github-actions-for-deployments\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/wpengine.com\/builders\/"},{"@type":"ListItem","position":2,"name":"GitHub Actions for Deployments"}]},{"@type":"WebSite","@id":"https:\/\/wpengine.com\/builders\/#website","url":"https:\/\/wpengine.com\/builders\/","name":"Builders","description":"Reimagining the way we build with WordPress.","publisher":{"@id":"https:\/\/wpengine.com\/builders\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/wpengine.com\/builders\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/wpengine.com\/builders\/#organization","name":"WP Engine","url":"https:\/\/wpengine.com\/builders\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wpengine.com\/builders\/#\/schema\/logo\/image\/","url":"https:\/\/wpengine.com\/builders\/wp-content\/uploads\/2024\/05\/WP-Engine-Horizontal@2x.png","contentUrl":"https:\/\/wpengine.com\/builders\/wp-content\/uploads\/2024\/05\/WP-Engine-Horizontal@2x.png","width":348,"height":68,"caption":"WP Engine"},"image":{"@id":"https:\/\/wpengine.com\/builders\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/wpebuilders","https:\/\/www.youtube.com\/channel\/UCh1WuL54XFb9ZI6m6goFv1g"]},{"@type":"Person","@id":"https:\/\/wpengine.com\/builders\/#\/schema\/person\/9d8d20c8a321b90faceae588fcf6d30d","name":"Damon Cook","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/18d75285d6803fab88b7f45601bb68cbac7c3956347217c06a0291e27dc65f6a?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/18d75285d6803fab88b7f45601bb68cbac7c3956347217c06a0291e27dc65f6a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/18d75285d6803fab88b7f45601bb68cbac7c3956347217c06a0291e27dc65f6a?s=96&d=mm&r=g","caption":"Damon Cook"},"description":"Damon Cook is a Developer Advocate at WP Engine. Previously, he navigated the WordPress agency land for a decade. He is a purveyor and discoverer of musical frisson. He can be found in the realms of WordPress Slack, WooCommerce Slack, and Twitter.","sameAs":["https:\/\/x.com\/dcook"],"url":"https:\/\/wpengine.com\/builders\/author\/damon-cook\/"}]}},"_links":{"self":[{"href":"https:\/\/wpengine.com\/builders\/wp-json\/wp\/v2\/posts\/5398","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpengine.com\/builders\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wpengine.com\/builders\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wpengine.com\/builders\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/wpengine.com\/builders\/wp-json\/wp\/v2\/comments?post=5398"}],"version-history":[{"count":0,"href":"https:\/\/wpengine.com\/builders\/wp-json\/wp\/v2\/posts\/5398\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wpengine.com\/builders\/wp-json\/wp\/v2\/media\/5309"}],"wp:attachment":[{"href":"https:\/\/wpengine.com\/builders\/wp-json\/wp\/v2\/media?parent=5398"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wpengine.com\/builders\/wp-json\/wp\/v2\/categories?post=5398"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wpengine.com\/builders\/wp-json\/wp\/v2\/tags?post=5398"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}