A common part of the WordPress® development workflow includes deploying certain parts of the site (like a custom theme or plugin) to the staging or live site on Flywheel when a developer makes a git commit and pushes it to GitHub (or another git repository).1 This article will walk you through the steps required to set this particular workflow up with GitHub and GitHub Actions.
The process looks a little like this:
/.github/workflows/
directory in your repo that contains instructions for GitHub to follow once you push to your repo/.github/workflows/
directory in your repo
Open up your favorite code editor and create an empty .github/
directory at the root of your project (typically your custom theme or plugin). Inside of that newly created directory, create another empty workflows/
directory. Finally, inside of workflows/
directory, create a file called main.yml
. The name of the YAML file really doesn’t matter as GitHub will simply look for a YAML file, but we’ll use main.yml
for our example.
The YAML config file must follow a certain syntax for GitHub to read it correctly. For our workflow, we just need name
, on
, and jobs
top-level keys. Here’s the full workflow that you can copy and paste! We’ll break it down below.
[code lang=”yaml”]
name: Flywheel SSH Deploy
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
– uses: actions/checkout@v2
– name: Deploy to Server
uses: easingthemes/[email protected]
env:
SSH_PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
REMOTE_HOST: ssh.getflywheel.com
REMOTE_USER: ${{ secrets.SSH_USER }}
ARGS: -rltgoDzvO –exclude .git –exclude .github
TARGET: /www/wp-content/themes/
[/code]
jobs:
. A full list of available values for this key can be found here, but we’ll stick to triggering the workflow when someone pushes to the branch named main
.build
(the name of the job doesn’t matter to the workflow– it can be whatever you want, but we recommend something semantic).easingthemes/ssh-deploy
Action to use, and then the unique information for your Flywheel server that’s needed to know where to push the code to.ssh.getflywheel.com
.ssh.getflywheel.com
. More information is listed below, but it should follow this syntax: your-flywheel-username+site-slug
.
As mentioned above, there are two variables that should be stored in the GitHub’s Secrets tab of your repository so that you’re not hard-coding confidential information into your repo.
To add these secrets, head over to your GitHub repo and select the “Settings” tab on the far right, then select “Secrets” towards the bottom of the left side navigation.
PRIVATE_KEY
Add a new secret and name it SSH_PRIVATE_KEY
. In the value field, you’ll want to paste the PEM format of your private SSH key. This must be the private key from the private/public key pair that you use for Flywheel SSH and must be in PEM format to work with the easingthemes/ssh-deploy Action. To convert the private key to PEM format, use this command, replacing id_rsa
with your private key name if the file name is different:
openssl rsa -in ~/.ssh/id_rsa -outform pem
If you would like to automatically copy the output of that command to your clipboard, pipe the command to the appropriate platform-specific command like so:
macOS: openssl rsa -in ~/.ssh/id_rsa -outform pem | pbcopy
Windows: openssl rsa -in ~/.ssh/id_rsa -outform pem | clip
More information on generating public and private keys can be found in this article.
SSH_USER
Add another new secret and name it REMOTE_USER
. The value should be the username of the site owner +
the site slug. Example: flytrevan+super-fly
. If the site is owned by an Organization the value should be team +
the username of the Organization +
the site slug. Example: team+pixel-design-studio+pie-hard
. More information on identifying the username and site slug can be found here.
You should now have everything in place and are ready to test out your workflow! You can commit your change to your local project and push to GitHub and GitHub Actions should now trigger a build. You can watch the progress of the build on the Actions tab of your repo in GitHub. If the workflow builds successfully, you should see a green checkmark next to the most recent commit.
New to Flywheel? Start here, we've got all the information you'll need to get started and launch your first site!
View allLearn all about managing your Flywheel user account, Teams and integrations.
View allFlywheel hosting plans include a ton of great features. Learn about how to get a free SSL certificate, set up a staging site, and more!
View allAll the server and setting info you'll need to help you get the most out of your Flywheel hosting plan!
View allTips and tricks for managing your sites on Flywheel, including going live, troubleshooting issues and migrating or cloning sites.
View allLearn more about Growth Suite, our all-in-one solution for freelancers and agencies to grow more quickly and predictably.
Getting started with Growth Suite
Growth Suite: What are invoice statuses?
Growth Suite: What do client emails look like?
Learn more about Managed Plugin Updates, and how you can keep your sites up to date, and extra safe.
Restoring Plugin and Theme Management on Flywheel
Managed Plugin Updates: Database upgrades
Managed Plugin Updates: Pause plugin updates
We can help! Check out our Brand Resources page for links to all of our brand assets.
Brand Resources