trellis-github-deployment

GitHub Actions and workflows to automate deployment of a Roots/Trellis project to staging and production environments.

MIT License

Stars
27
Committers
1

example.com

This Trellis-based WordPress project uses GitHub Actions for continuous deployment.

Deployment

Deployment occurs automatically from this GitHub repository using GitHub Actions.

This project deploys to the staging and production environments when a pull_request is merged to staging or main branches respectively.

GitHub Deployments maintain a history of deployments and provide links to the current deployments in each.

See the current deployments

Note: these instructions presume your staging and production environments (servers) and DNS are already configured.

System Requirements

1. Create GitHub Secrets

Deployment relies on 4 GitHub secrets:

Modify and run the following to generate these secrets:

trellis key generate && gh secret set ANSIBLE_VAULT_PASSWORD -b $(cat trellis/.vault_pass) && gh secret set TRELLIS_SITE_SLUG -b example.com

Secrets

  • TRELLIS_DEPLOY_SSH_PRIVATE_KEY - A private key used by GitHub to connect to your environments.
  • TRELLIS_DEPLOY_SSH_KNOWN_HOSTS - known_hosts keys for your environments.
  • ANSIBLE_VAULT_PASSWORD - Your new Trellis project's vault password.
  • TRELLIS_SITE_SLUG - The slug from your new Trellis project's wordpress_sites.yml file.

2. Generate Trellis aliases

From your site directory, run:

trellis alias

And update site/wp-cli.yml as instructed.

3. Grant workflow permissions

  1. In this repository, navigate to Settings -> Actions -> General -> Workflow Permissions.
  2. Enable "read and write" permissions.

4. Reprovision your environments to allow GitHub's deploy key

Run the following:

trellis provision staging && trellis provision production

Development

  1. Clone this repository locally
  2. In the repository directry, run trellis init
  3. In the repository directory, run trellis up