diff --git a/.github/workflows/deploy-pantheon.yml b/.github/workflows/deploy-pantheon.yml new file mode 100644 index 0000000..9f2b34c --- /dev/null +++ b/.github/workflows/deploy-pantheon.yml @@ -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 }}" diff --git a/README.md b/README.md index 16bc4f3..46fa601 100644 --- a/README.md +++ b/README.md @@ -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`