Skip to content

Instantly share code, notes, and snippets.

@mattradford
Created February 10, 2021 19:43
Show Gist options
  • Save mattradford/f19fc39edb0c0f3479d9f30406750401 to your computer and use it in GitHub Desktop.
Save mattradford/f19fc39edb0c0f3479d9f30406750401 to your computer and use it in GitHub Desktop.
WordPress theme build and deploy
name: WordPress Build & Deploy Theme
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-18.04
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Validate composer.json and composer.lock
run: composer validate
- name: Cache Composer packages
uses: actions/cache@v2
id: composer-cache
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install composer dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress --no-suggest
- name: Install node
uses: actions/setup-node@v2
with:
node-version: '15'
- name: Install NPM
run: npm install
- name: Build assets
run: npm run prod
- name: Setup SSH agent
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.KEY }}
- name: Verify host
run: ssh-keyscan ${{ secrets.HOST }} >> ~/.ssh/known_hosts
- name: Sync project files
run: rsync -avzr --delete --exclude={'/.git','/.github','/.gitignore','/*.config.js','/LICENSE','/*.md','/*.json','/*.mix.js','/src','/ruleset.xml','/composer.lock'} ${GITHUB_WORKSPACE}/ ${{ secrets.USERNAME }}@${{ secrets.HOST }}:${{ secrets.DEPLOY_PATH }}
- name: Flush WordPress cache
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
# script: wp cache flush
script: whoami
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment