Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions .github/workflows/deploy-pantheon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Deploy to Pantheon

on:
workflow_call:
inputs:
site:
description: "The site you are deploying to on the pantheon platform"
required: false
default: "_wpeprivate/releases"
type: string
deployment_id:
description: "The deployment ID from previous jobs"
required: true
type: string
workflow_run_id:
description: "Workflow Run ID to get artifacts from"
required: true
type: string
do_backup:
# @todo implement remote backups on Pantheon possibly using terminus
description: "Backup the current site before deploying"
required: false
default: false
type: boolean
environment:
description: "The Environment to deploy and grab env.vars from"
required: true
type: string
inherit_build:
description: "This allows projects with multiple deployments to share a build from another job, it must be provided a job ID"
required: false
type: string

jobs:
deploy:
name: To ${{ vars.HOST }}
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:
- name: Deployment In Progress
id: in_progress_deployment
uses: octokit/request-action@v2
with:
route: POST /repos/{repo}/deployments/{deployment}/statuses
repo: ${{ github.repository }}
deployment: ${{ inputs.deployment }}
environment: ${{ vars.ENVIRONMENT }}
environment_url: ${{ vars.SITE_URL }}
log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
state: in_progress
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

- name: Install Terminus
uses: pantheon-systems/terminus-github-actions@v1
with:
pantheon-machine-token: ${{ secrets.PANTHEON_MACHINE_TOKEN }}

- name: Push to Pantheon
uses: pantheon-systems/push-to-pantheon@0.6.0
with:
ssh_key: ${{ secrets.SSH_KEY }}
machine_token: ${{ secrets.PANTHEON_MACHINE_TOKEN }}
site: ${{ vars.PANTHEON_SITE_MACHINE_NAME }}

- name: Set Deployment Status as Successful
if: ${{ success() }}
uses: octokit/request-action@v2.x
with:
route: POST /repos/{repo}/deployments/{deployment}/statuses
repo: ${{ github.repository }}
deployment: ${{ inputs.deployment }}
environment: ${{ vars.ENVIRONMENT }}
environment_url: ${{ vars.SITE_URL }}
log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
state: success
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

- name: Set Deployment Status as Failboat
if: ${{ failure() }}
uses: octokit/request-action@v2.x
with:
route: POST /repos/{repo}/deployments/{deployment}/statuses
repo: ${{ github.repository }}
deployment: ${{ inputs.deployment }}
environment: ${{ vars.ENVIRONMENT }}
environment_url: ${{ vars.SITE_URL }}
log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
state: failure
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ To learn more [about variables](https://docs.github.com/en/actions/writing-workf
| PLUGINS | | A JSON formatted array of plugins to build Ex `["linchpin-functionality"]` |
| THEME_USES_COMPOSER | false | Do the theme(s) use composer to load dependencies |
| PLUGIN_USES_COMPOSER | true | Do the plugins(s) use composer to load dependencies |
| PANTHEON_MACHINE_TOKEN | | When using Pantheon this is how we authenticate |
| PANTHEON_SITE_MACHINE_NAME | | WHen using Pantheon this is out we reference our site |


## Breaking Changes from `main` or `v2`

Expand Down