Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ilanvivanco/wpe-deployment-action
Set automatic deployments to WPEngine using an SSH private key and rsync.
https://github.com/ilanvivanco/wpe-deployment-action
action actions deploy deployment github-actions
Last synced: about 2 months ago
JSON representation
Set automatic deployments to WPEngine using an SSH private key and rsync.
- Host: GitHub
- URL: https://github.com/ilanvivanco/wpe-deployment-action
- Owner: IlanVivanco
- License: mit
- Created: 2021-07-30T22:04:43.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-09-06T18:56:14.000Z (over 2 years ago)
- Last Synced: 2024-10-13T13:02:21.828Z (3 months ago)
- Topics: action, actions, deploy, deployment, github-actions
- Language: Shell
- Homepage:
- Size: 19.5 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Automatic WordPress deployment to WP Engine
> [!WARNING]
> This repo has been archived and moved [here](https://github.com/IlanVivanco/wp-deployment-action), to extend capabilities and add support for a new server.This GitHub Action can be used to set automatic deployments using an SSH private key and **rsync**.
By default, the action will deploy the repository root directory, but you can optionally deploy a theme, plugin, or any other directory using the `SOURCE_PATH`. Likewise, if you need to specify a different destination directory, you can do so using `PUBLISH_PATH`.
After the deployment, this action will also purge your WP Engine cache and flush permalinks to ensure all changes are visible.
## GitHub Action workflow
1. Set up your [SSH key](#setting-up-your-ssh-key) on WP Engine.
1. Create a new YML file in the directory `.github/workflows/` in the root of your repository. You can choose any name, e.g., `deploy.yml`.
1. Add the following code to this new file, replacing values for `PRD_BRANCH` and `PRD_ENV` accordingly.
**`> .github/workflows/deploy.yml`**
```yml
name: 📦 Deploy to WP Engine
on:
push:
workflow_dispatch:jobs:
build:
name: 🚩 Starting deployment job
runs-on: ubuntu-latest
steps:
- name: 🚚 Getting latest code
uses: actions/checkout@v2- name: 🔁 Deploying to WP Engine
uses: IlanVivanco/wpe-deployment-action@main
env:
# Deployment options.
WPE_SSH_KEY: ${{ secrets.WPE_SSH_KEY }}
SOURCE_PATH: ''
PUBLISH_PATH: ''# You must, at least, set the production environment.
PRD_BRANCH: main
PRD_ENV: prodinstall# Uncomment this for setting a staging environment.
# STG_BRANCH: staging
# STG_ENV: stageinstall# Uncomment this for setting a development environment.
# DEV_BRANCH: dev
# DEV_ENV: devinstall
```1. Finally, push the latest changes to the repository, the action will do the rest.
![Magic](https://media.giphy.com/media/l3V0dy1zzyjbYTQQM/giphy.gif)
> ℹ You can have multiple branches deploying to the same install by separating them with a comma, e.g., `PRD_BRANCH: main, dev, staging` will deploy all three branches to the WP Engine production environment. Using regex here, well help you to extend this to even more branches, e.g., `main, feature(/.*)?` will deploy the _main_ banch and also the _feature_ or _feature/anything_ branches.
## Setting up your SSH key
1. [Generate a new SSH key pair](https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/) as a special deploy key between your GitHub Repo and WP Engine. The simplest method is to generate a key pair with a blank passphrase, which creates an unencrypted private key.
1. Add the public SSH key to your [WP Engine SSH Keys](https://wpengine.com/support/ssh-gateway/#Add_SSH_Key) configuration panel.
1. Store the private key in the GitHub repository as new [GitHub encrypted secret](https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository) using the name `WPE_SSH_KEY` save it —this can be customized if you change the secret name in the yml file to call it correctly—.
## Ignoring files
If you want some files to be ignored upon deployment, you can create a `.deployignore` file on your source directory, adding the exclude patterns —one per line—. Blank lines and lines starting with _#_ will be ignored.
**`> .deployignore`**
```bash
# Exclude rules
bin
composer*
dist
gulp*
node_modules
package*
phpcs*
src
vendor
```## Environment variables
### Required
| Name | Type | Usage |
| ------------- | --------- | ----------------------------------------------------------------------------------------- |
| `WPE_SSH_KEY` | _secrets_ | Authorized SSH private key for deployment. See [SSH key usage](#setting-up-your-ssh-key). |
| `PRD_BRANCH` | _string_ | Name of the branch you would like to deploy from, e.g., "_main_". |
| `PRD_ENV` | _string_ | Name of the WP Engine Prod environment you want to deploy to. |### Optional
| Name | Type | Usage |
| -------------- | -------- | --------------------------------------------------------------------------------------------------------------------------- |
| `STG_BRANCH` | _string_ | Name of the staging branch you would like to deploy from. |
| `STG_ENV` | _string_ | Name of the the WP Engine Stage environment you want to deploy to. |
| `DEV_BRANCH` | _string_ | Name of the a development branch you would like to deploy from. |
| `DEV_ENV` | _string_ | Name of the the WP Engine Dev environment you want to deploy to. |
| `SOURCE_PATH` | _string_ | Path to specify a theme, plugin, or any other directory source to deploy from. Defaults to the repository root. |
| `PUBLISH_PATH` | _string_ | Path to specify a theme, plugin, or any other directory destination to deploy to. Defaults to the WordPress root directory. |
| `FAIL_CODE` | _number_ | Code number to be used if the action fails (0 = success and 1 = error). Defaults to 1. |### Additional Resources
- [Generate a new SSH key pair](https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/)
- [Setting up SSH on WP Engine](https://wpengine.com/support/ssh-gateway/)
- [Storing secrets in GitHub](https://docs.github.com/en/actions/reference/encrypted-secrets)### Contributing
Contributions to this action are always welcome and highly encouraged.
### License & Attribution
- Licensed as MIT © [Ilán Vivanco](https://ilanvivanco.com) 2021.
- This action is based on the work made by Alex Zuniga on [GitHub Action for WP Engine Site Deployments](https://github.com/wpengine/github-action-wpe-site-deploy).