├── Dockerfile ├── README.md └── entrypoint.sh /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:9.7-slim 2 | 3 | LABEL "com.github.actions.name"="GitHub Action for WP Engine Git Deployment" 4 | LABEL "com.github.actions.description"="An action to deploy your repository to a WP Engine site via git." 5 | LABEL "com.github.actions.icon"="chevrons-right" 6 | LABEL "com.github.actions.color"="blue" 7 | 8 | LABEL "repository"="http://github.com/jovrtn/github-action-wpengine-git-deploy" 9 | LABEL "maintainer"="Jesse L.K. Overton " 10 | 11 | RUN apt-get update && apt-get install -y git 12 | 13 | ADD entrypoint.sh /entrypoint.sh 14 | ENTRYPOINT ["/entrypoint.sh"] 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # THIS PROJECT IS UNMAINTAINED -- USE AT YOUR OWN RISK. PLEASE FORK OR SEE ONE OF THE EXISTING FORKS FOR A MORE UPDATED VERSION. 2 | 3 | # GitHub Action for WP Engine Git Deployments 4 | 5 | An action to deploy your repository to a **[WP Engine](https://wpengine.com)** site via git. [Read more](https://wpengine.com/git/) about WP Engine's git deployment support. 6 | 7 | ## Example GitHub Action workflow 8 | 9 | ``` 10 | workflow "Deploy to WP Engine" { 11 | on = "push" 12 | resolves = ["Git Push to Production"] 13 | } 14 | 15 | action "Git Push to Production" { 16 | uses = "jovrtn/github-action-wpengine-git-deploy@master" 17 | env = { 18 | WPENGINE_ENVIRONMENT_NAME = "my-cool-site-production" 19 | } 20 | secrets = [ 21 | "WPENGINE_SSH_KEY_PRIVATE", 22 | "WPENGINE_SSH_KEY_PUBLIC" 23 | ] 24 | } 25 | ``` 26 | 27 | ## Environment Variables & Secrets 28 | 29 | ### Required 30 | 31 | | Name | Type | Usage | 32 | |-|-|-| 33 | | `WPENGINE_ENVIRONMENT_NAME` | Environment Variable | The name of the WP Engine environment you want to deploy to. | 34 | | `WPENGINE_SSH_KEY_PRIVATE` | Secret | Private SSH key of your WP Engine git deploy user. See below for SSH key usage. | 35 | | `WPENGINE_SSH_KEY_PUBLIC` | Secret | Public SSH key of your WP Engine git deploy user. See below for SSH key usage. | 36 | 37 | ### Optional 38 | 39 | | Name | Type | Usage | 40 | |-|-|-| 41 | | `WPENGINE_ENVIRONMENT` | Environment Variable | Defaults to `production`. You shouldn't need to change this, but if you're using WP Engine's legacy staging, you can override the default and set to `staging` if needed. | 42 | | `LOCAL_BRANCH` | Environment Variable | Set which branch in your repository you'd like to push to WP Engine. Defaults to `master`. | 43 | 44 | ### Further reading 45 | 46 | * [Defining environment variables in GitHub Actions](https://developer.github.com/actions/creating-github-actions/accessing-the-runtime-environment/#environment-variables) 47 | * [Storing secrets in GitHub repositories](https://developer.github.com/actions/managing-workflows/storing-secrets/) 48 | 49 | ## Setting up your SSH keys 50 | 51 | 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. The simplest method is to generate a key pair with a blank passphrase, which creates an unencrypted private key. 52 | 2. Store your public and private keys in your GitHub repository as new 'Secrets' (under your repository settings), using the names `WPENGINE_SSH_KEY_PRIVATE` and `WPENGINE_SSH_KEY_PUBLIC` respectively. In theory, this replaces the need for encryption on the key itself, since GitHub repository secrets are encrypted by default. 53 | 3. Add the public key to your target WP Engine environment. 54 | 4. Per the [WP Engine documentation](https://wpengine.com/git/), it takes about 30-45 minutes for the new SSH key to become active. 55 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -l 2 | 3 | set -e 4 | 5 | : ${WPENGINE_ENVIRONMENT_NAME?Required environment name variable not set.} 6 | : ${WPENGINE_SSH_KEY_PRIVATE?Required secret not set.} 7 | : ${WPENGINE_SSH_KEY_PUBLIC?Required secret not set.} 8 | 9 | SSH_PATH="$HOME/.ssh" 10 | WPENGINE_HOST="git.wpengine.com" 11 | KNOWN_HOSTS_PATH="$SSH_PATH/known_hosts" 12 | WPENGINE_SSH_KEY_PRIVATE_PATH="$SSH_PATH/wpengine_key" 13 | WPENGINE_SSH_KEY_PUBLIC_PATH="$SSH_PATH/wpengine_key.pub" 14 | WPENGINE_ENVIRONMENT_DEFAULT="production" 15 | WPENGINE_ENV=${WPENGINE_ENVIRONMENT:-$WPENGINE_ENVIRONMENT_DEFAULT} 16 | LOCAL_BRANCH_DEFAULT="master" 17 | BRANCH=${LOCAL_BRANCH:-$LOCAL_BRANCH_DEFAULT} 18 | 19 | mkdir "$SSH_PATH" 20 | 21 | ssh-keyscan -t rsa "$WPENGINE_HOST" >> "$KNOWN_HOSTS_PATH" 22 | 23 | echo "$WPENGINE_SSH_KEY_PRIVATE" > "$WPENGINE_SSH_KEY_PRIVATE_PATH" 24 | echo "$WPENGINE_SSH_KEY_PUBLIC" > "$WPENGINE_SSH_KEY_PUBLIC_PATH" 25 | 26 | chmod 700 "$SSH_PATH" 27 | chmod 644 "$KNOWN_HOSTS_PATH" 28 | chmod 600 "$WPENGINE_SSH_KEY_PRIVATE_PATH" 29 | chmod 644 "$WPENGINE_SSH_KEY_PUBLIC_PATH" 30 | 31 | git config core.sshCommand "ssh -i $WPENGINE_SSH_KEY_PRIVATE_PATH -o UserKnownHostsFile=$KNOWN_HOSTS_PATH" 32 | git remote add $WPENGINE_ENV git@$WPENGINE_HOST:$WPENGINE_ENV/$WPENGINE_ENVIRONMENT_NAME.git 33 | git push -fu $WPENGINE_ENV $BRANCH:master 34 | --------------------------------------------------------------------------------