Home

Awesome

Pantheon WordPress Deploy Action

Deploy WordPress sites to Pantheon

Support Level Release Version GPLv3 License Automated Tests

Pantheon has its own deployment workflow called "WebOps" which is based around a unique, git-driven infrastructure. All environments on Pantheon are version-controlled with git, this includes WordPress core, plugins, themes, etc. Pantheon's master branch is tied to the Dev environment, from there you need to manually(from the dashboard or via the Terminus CLI) promote the content to Pantheon's Test environment and ultimately to the Live site which is the production environment. At 10up, the code in the git's main branch is production ready(preprod and production environments only) therefore our preferred deployment workflow for Github + Pantheon sites is:

Requirements

Inputs

NameRequiredDescription
pantheon_git_urlTruePantheon's Git URL
multidev_env_nameFalsePantheon's multidev environment name. If set, the Github action will deploy to a multidev environment with the same name. This input is ignored on actions executed from the main branch
working_dirFalseDirectory containing the WordPress built site
site_nameFalsePantheon's site name
terminus_tokenFalseToken to authenticate with the Terminus CLI. See instructions to generate machine tokens here
ssh_private_keyTruePrivate SSH Key to access the Pantheon's repository. The public key must be added to Pantheon, see instructions here
wordpress_versionTrueWordPress core version to fetch into the site from Pantheon's upstream before deploying to Pantheon
root_filesFalseFiles to copy in the WordPress root directory. e.g. pantheon.yml, wp-config.php, etc
git_user_nameFalseGIT user name needed to pull and push to the Pantheon's repository
git_user_emailFalseGIT user email address needed to pull and push to the Pantheon's repository
promote_test_to_liveFalseBackups Pantheon Live site and promotes Test to Live. If this value is set to yes(must be an exact match) the action will only backup the Live site, promote Test to Live and then exits; all other steps will be ignored. This input is applied on actions executed from the main branch only. The workflow must use workflow_dispatch as trigger in order to manually execute this action

Examples

Deploy to a multidev environment

This example assumes the WordPress site has been previously built inside the payload directory following the structure described here

name: Deploy

on:
  push:
    branches:
      - staging

jobs:
  deploy:
    name: Deploy built site to Pantheon
    runs-on: ubuntu-latest

    steps:
      # Fetch previously built site.
      - name: Fetch artifact
        uses: actions/cache@v3
        with:
          path: payload
          key: ${{ github.sha }}

      # Deploy to Pantheon
      - name: Deploy to Pantheon
        uses: 10up/pantheon-wp-deploy-action@v1
        with:
          pantheon_git_url: "${{ secrets.PANTHEON_GIT_URL }}"
          multidev_env_name: "staging"
          ssh_private_key: "${{ secrets.PRIVATE_KEY }}"
          wordpress_version: "6.4.3"
          working_dir: "./payload"
          root_files: "pantheon.yml wp-config.php"

Deploy to Pantheon's Dev environment and automatically promotes Dev to Test

This example assumes the WordPress site has been previously built inside the payload directory following the structure described here

name: Deploy

on:
  push:
    branches:
      - trunk

jobs:
  deploy:
    name: Deploy built site to Pantheon
    runs-on: ubuntu-latest

    steps:
      # Fetch previously built site.
      - name: Fetch artifact
        uses: actions/cache@v3
        with:
          path: payload
          key: ${{ github.sha }}

      # Deploy to Pantheon
      - name: Deploy to Pantheon
        uses: 10up/pantheon-wp-deploy-action@v1
        with:
          pantheon_git_url: "${{ secrets.PANTHEON_GIT_URL }}"
          ssh_private_key: "${{ secrets.PRIVATE_KEY }}"
          terminus_token: "${{ secrets.TERMINUS_TOKEN }}"
          site_name: "my-pantheon-site"
          wordpress_version: "6.4.3"
          working_dir: "./payload"
          root_files: "pantheon.yml wp-config.php"

Deploy to Pantheon's Dev environment only (not recommended)

This example assumes the WordPress site has been previously built inside the payload directory following the structure described here

name: Deploy

on:
  push:
    branches:
      - trunk

jobs:
  deploy:
    name: Deploy built site to Pantheon
    runs-on: ubuntu-latest

    steps:
      # Fetch previously built site.
      - name: Fetch artifact
        uses: actions/cache@v3
        with:
          path: payload
          key: ${{ github.sha }}

      # Deploy to Pantheon
      - name: Deploy to Pantheon
        uses: 10up/pantheon-wp-deploy-action@v1
        with:
          pantheon_git_url: "${{ secrets.PANTHEON_GIT_URL }}"
          ssh_private_key: "${{ secrets.PRIVATE_KEY }}"
          site_name: "my-pantheon-site"
          wordpress_version: "6.4.3"
          working_dir: "./payload"
          root_files: "pantheon.yml wp-config.php"

By not adding the terminus_token the action will skip the step to automatically promote Dev to Test

Deploy to Pantheon's Live environment

In this example the inputs pantheon_git_url, ssh_private_key and wordpress_version aren't being used by the Github action but they are marked as required in the actions.yml so we add them to prevent the action from failing

name: Promote Test to Live

on: workflow_dispatch

jobs:
  deploy:
    name: Promote Test to Live
    runs-on: ubuntu-latest

    steps:
      - name: Promote Test to Live
        uses: 10up/pantheon-wp-deploy-action@v1
        with:
          pantheon_git_url: "${{ secrets.PANTHEON_GIT_URL }}"
          ssh_private_key: "${{ secrets.PRIVATE_KEY }}"
          terminus_token: "${{ secrets.TERMINUS_TOKEN }}"
          wordpress_version: "6.4.3"
          site_name: "my-pantheon-site"
          promote_test_to_live: "yes"

Support Level

Active: 10up is actively working on this, and we expect to continue work for the foreseeable. Bug reports, feature requests, questions, and pull requests are welcome.

Changelog

A complete listing of all notable changes to this Github Action are documented in CHANGELOG.md.

Contributing

Please read CODE_OF_CONDUCT.md for details on our code of conduct, CONTRIBUTING.md for details on the process for submitting pull requests to us, and CREDITS.md for a listing of maintainers and contributors.

Like what you see?

<p align="center"> <a href="http://10up.com/contact/"><img src="https://10up.com/uploads/2016/10/10up-Github-Banner.png" width="850"></a> </p>