Skip to content

Instantly share code, notes, and snippets.

@mizner
Created October 5, 2022 17:03
Show Gist options
  • Save mizner/d6d4f1a5e94698e2b643e975c1cbb45e to your computer and use it in GitHub Desktop.
Save mizner/d6d4f1a5e94698e2b643e975c1cbb45e to your computer and use it in GitHub Desktop.
Example of Circle CI deployment to WP Engine
version: 2.1
# Environment Variables: https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables
# https://circleci.com/docs/2.0/reusing-config/#authoring-reusable-commands
orbs:
slack: circleci/slack@3.3.0
commands:
setup:
description: "Setup our build"
steps:
- run:
name: "Remove all .gitignore files"
command: find . -name ".gitignore" -exec rm -f {} \;
- run:
name: "Add WPEngine to known hosts"
command: ssh-keyscan -H git.wpengine.com >> ~/.ssh/known_hosts
npm:
description: "Run NPM tasks"
parameters:
npm_script:
default: "build"
type: string
steps:
- run: |
yarn install --frozen-lockfile
yarn << parameters.npm_script >>
composer:
description: "Install Composer Packages (including WordPress Plugins from wpackagist, satis, etc.)"
steps:
- run: composer install --no-dev --optimize-autoloader
clean:
description: "Remove files we don't want pushed to the server"
steps:
- run: |
rm -rf $(cat .clean)
find . -name 'node_modules' -type d -prune -exec rm -rf '{}' +
find . -name '.gitignore' -type d -prune -exec rm -rf '{}' +
find . -name 'starter-files' -type d -prune -exec rm -rf '{}' +
git_push:
description: "Deploy our files"
parameters:
repo:
type: string
steps:
- run:
name: "Push files to WPEngine"
command: |
git add .
git commit -m "deploy!"
git push -f << parameters.repo >> ${CIRCLE_BRANCH}
notify:
description: "Send notification about the deployment"
steps:
- slack/notify:
color: "#1C2375"
mentions: "here"
message: "A new commit has been pushed to ${CIRCLE_BRANCH}"
webhook: "#"
# https://circleci.com/docs/2.0/configuration-reference/#jobs
jobs:
prod:
docker:
- image: pyxl/wordpress-ci-cd-2020
steps:
- checkout
- setup
- composer
- npm:
npm_script: "prod"
- clean
- git_push:
repo: ${GIT_DEPLOY_PRODUCTION}
stag:
docker:
- image: pyxl/wordpress-ci-cd-2020
steps:
- checkout
- setup
- composer
- npm:
npm_script: "prod"
- clean
- git_push:
repo: ${GIT_DEPLOY_STAGING}
dev:
docker:
- image: pyxl/wordpress-ci-cd-2020
steps:
- checkout
- setup
- composer
- npm:
npm_script: "prod"
- clean
- git_push:
repo: ${GIT_DEPLOY_DEVELOPMENT}
- notify
workflows:
version: 2
deploy:
jobs:
- prod:
filters:
branches:
only:
- production
- stag:
filters:
branches:
only:
- /release/.*/
- dev:
filters:
branches:
only:
- /bug/.*/
- /feature/.*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment