Skip to content

Commit

Permalink
refactor: break workflow into two files for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
dustin-jw committed Oct 31, 2023
1 parent 06db35f commit 8487105
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy to Pantheon
name: Deploy to Pantheon (Git)

on:
push:
Expand All @@ -7,7 +7,7 @@ on:

jobs:
deploy:
if: ${{ vars.DEPLOY_TO_PANTHEON_GIT || vars.DEPLOY_TO_PANTHEON_SFTP }}
if: ${{ vars.DEPLOY_TO_PANTHEON_GIT }}
runs-on: ubuntu-latest

strategy:
Expand Down Expand Up @@ -46,9 +46,7 @@ jobs:
eval `ssh-agent`
ssh-add ~/.ssh/id_rsa
# Git-specific deployment steps
- name: Checkout Pantheon remote
if: ${{ vars.DEPLOY_TO_PANTHEON_GIT }}
run: |
git config --global user.email "${{ secrets.PRODUCTION_USER_EMAIL }}"
git config --global user.name "${{ secrets.PRODUCTION_USER_NAME }}"
Expand All @@ -57,7 +55,6 @@ jobs:
git worktree add --track -b prod prod pantheon/master
- name: Copy build artifacts
if: ${{ vars.DEPLOY_TO_PANTHEON_GIT }}
run: |
rm -rf prod/vendor prod/wp-content/plugins prod/wp-content/themes/sparkpress
cp -r vendor prod
Expand All @@ -66,17 +63,10 @@ jobs:
mkdir -p wp-content/plugins
cp -r wp-content/plugins prod/wp-content/plugins
- name: Deploy to Pantheon via Git
if: ${{ vars.DEPLOY_TO_PANTHEON_GIT }}
- name: Deploy to Pantheon
run: |
cd prod
git status | grep "nothing to commit" && exit 0 || git status
git add .
git commit -m "Prod release"
git push pantheon HEAD:master
# SFTP-specific deployment steps
- name: Deploy to Pantheon via SFTP
if: ${{ vars.DEPLOY_TO_PANTHEON_SFTP }}
run: |
echo "This is a test"
52 changes: 52 additions & 0 deletions .github/workflows/deploy.pantheon.sftp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Deploy to Pantheon (SFTP)

on:
push:
branches: [main]
workflow_dispatch:

jobs:
deploy:
if: ${{ vars.DEPLOY_TO_PANTHEON_SFTP }}
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x]

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install npm dependencies
run: npm ci

- name: Install PHP dependencies with Composer
uses: php-actions/composer@v6
with:
php_version: '8.1'
version: 2.x

- name: Build theme
run: npm run build:prod

- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.PANTHEON_ID_RSA }}
known_hosts: ${{ secrets.KNOWN_HOSTS }}

- name: Add SSH Key
run: |
eval `ssh-agent`
ssh-add ~/.ssh/id_rsa
- name: Deploy to Pantheon via SFTP
if: ${{ vars.DEPLOY_TO_PANTHEON_SFTP }}
run: |
echo "This is a test"

0 comments on commit 8487105

Please sign in to comment.