1. ryanshoover/wpengine@0.7.8

ryanshoover/wpengine@0.7.8

Sections
Commands, Executors, and Jobs for testing a WordPress site and for deploying to WP Engine installs.
Created: January 8, 2019Version Published: December 9, 2021Releases: 60
Org Usage:
< 25

Orb Quick Start Guide

Use CircleCI version 2.1 at the top of your .circleci/config.yml file.

1 version: 2.1

Add the orbs stanza below your version, invoking the orb:

1 2 orbs: wpengine: ryanshoover/wpengine@0.7.8

Use wpengine elements in your existing workflows and jobs.

Opt-in to use of uncertified orbs on your organization’s Security settings page.

Usage Examples

wordpress-plugin

A sample CircleCI config file that uses the ryanshoover/wpengine orb to run lint and codeception on a WordPress plugin. It also deploys tags to a Gemfury repository.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 orbs: wpengine: ryanshoover/wpengine@x.y.z version: 2.1 workflows: test-deploy: jobs: - wpengine/build - wpengine/lint: requires: - wpengine/build - wpengine/codeception: package_name: my-custom-plugin package_type: plugin requires: - wpengine/build - wpengine/deploy_fury: filters: branches: ignore: /.*/ tags: only: /^\d+\.\d+\.\d+$/ requires: - wpengine/lint - wpengine/codeception version: 2

wordpress-site

A sample CircleCI config file that uses the ryanshoover/wpengine orb to test a site repo at every stage, deploy the site to WP Engine environments, and run regressions on the staging site.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 orbs: wpengine: ryanshoover/wpengine@x.y.z version: 2.1 workflows: build_test_deploy: jobs: - wpengine/build - wpengine/lint: requires: - wpengine/build - wpengine/codeception: requires: - wpengine/build - wpengine/deploy_site: environment: development filters: branches: only: development name: deploy-development requires: - wpengine/lint - wpengine/codeception - wpengine/deploy_site: environment: staging filters: branches: only: staging name: deploy-staging pipeline_id: << pipeline.id >> regression_enabled: true requires: - wpengine/lint - wpengine/codeception - wpengine/deploy_site: environment: production filters: branches: only: - master - production name: deploy-production pipeline_id: << pipeline.id >> regression_enabled: true requires: - wpengine/lint - wpengine/codeception - wpengine/backup - wpengine/deploy_site: environment: thenameofmyfeatureinstall filters: branches: only: - /feat-.*/ name: deploy-feature requires: - wpengine/lint - wpengine/codeception - wpengine/deploy_site: environment: qa filters: branches: only: - /deploy-.*/ name: deploy-site requires: - wpengine/lint - wpengine/codeception regression: jobs: - wpengine/backstop_reference: config: tests/backstop/ context: DXT filters: branches: only: - staging - master - hold-for-deploy: requires: - wpengine/backstop_reference type: approval - wpengine/backstop_test: config: tests/backstop/ context: DXT requires: - hold-for-deploy version: 2

Jobs

backstop_reference

Run visual regression tests using backstopjs

Show job Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
config
Path to the backstop config file
Yes
-
string

backstop_test

Run visual regression tests using backstopjs

Show job Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
config
Path to the backstop config file
Yes
-
string

backup

Generate a backup of production prior to deployment. `yarn run dxt-backup`

Show job Source

build

Build a plugin, theme, or site. Installs composer and yarn dependencies. Runs yarn build command.

Show job Source

codeception

Run codeception tests for end-to-end testing on a WordPress site. Codeception supports unit, wpunit, functional, and acceptance testing.

Show job Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
package_name
Name of the plugin or theme (directory name)
No
project
string
package_type
Is this a WordPress plugin or theme
No
project
enum

deploy_fury

Deploy a PHP, Node, or Ruby package to a Gemfury repository. Designed to be run on new GitHub releases.

Show job Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
project
Project name
No
CIRCLE_PROJECT_REPONAME
env_var_name
token
Gemfury PUSH token
No
GEMFURY_TOKEN_PUSH
env_var_name
user
Gemfury user or team name
No
GEMFURY_USER
env_var_name

deploy_pr

Create deploy pull requests, `Staging ← Development` and `Master ← Staging`

Show job Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
target
Target branch to be the PR base
Yes
-
string

deploy_site

Build and deploy the codebase to a WP Engine environment

Show job Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
environment
Are we deploying to the production, staging, development, or custom environment? Production, staging, and development need a corresponding environment variable defined in CircleCI's project configuration. An optional `./.gitignores/__deployment` file can be used to deploy build files rather than source files.
Yes
-
string
pipeline_id
Pipeline ID from the job. The orb can't access the ID directly for security reasons
No
00000000-0000-0000-0000-000000000001
string
regression_enabled
Should we try to approve a regression workflow? If you have a regression workflow that runs in parallel to your deploy workflows, set this to be true. The regression workflow's "hold for approval" job will be approved once the deploy finishes.
No
false
boolean
regression_job
Name of the job that needs approved
No
hold-for-deploy
string
regression_workflow
Name of the regression workflow that needs approved
No
regression
string
rollbar_token
API token for accessing Rollbar
No
ROLLBAR_ACCESS_TOKEN
env_var_name

lint

Lint the files to make sure everything follows best practices. `yarn run lint` can be a combination of phpcs, jslint, sass-lint, and more

Show job Source

Commands

approve_hold_for_deploy

Approves the regression workflow that is waiting for the deploy to finish

Show command Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
circle_token
Environment variable that contains a CircleCI API token
No
CIRCLE_TOKEN
env_var_name
pipeline_id
Pipeline ID from the job. The orb can't access the ID directly for security reasons
Yes
-
string
regression_job
Name of the job that needs approved
No
hold-for-deploy
string
regression_workflow
Name of the regression workflow that needs approved
No
regression
string

find_wpe_install

Set up our WPE_Install based on the environment

Show command Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
environment
Are we deploying to the production, staging, development, or custom environment? Production, staging, and development need a corresponding environment variable defined in CircleCI's project configuration. An optional `./.gitignores/__deployment` file can be used to deploy build files rather than source files.
No
undefined
string

gitignoreswap

Swaps gitignore file for one that

Show command Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
gitignore_type
Type of gitignore file to load
No
site
enum

Orb Source

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 # This code is licensed from CircleCI to the user under the MIT license. # See here for details: https://circleci.com/developer/orbs/licensing commands: approve_hold_for_deploy: description: | Approves the regression workflow that is waiting for the deploy to finish parameters: circle_token: default: CIRCLE_TOKEN description: Environment variable that contains a CircleCI API token type: env_var_name pipeline_id: description: Pipeline ID from the job. The orb can't access the ID directly for security reasons type: string regression_job: default: hold-for-deploy description: Name of the job that needs approved type: string regression_workflow: default: regression description: Name of the regression workflow that needs approved type: string steps: - run: command: | # shellcheck disable=SC1073 WORKFLOW=$( curl --location \ --request GET "https://circleci.com/api/v2/pipeline/<< parameters.pipeline_id >>/workflow" \ -u "$<< parameters.circle_token >>:" \ | jq -r ".items[] | select( .name == \"<< parameters.regression_workflow >>\" ) | .id" ) echo "export WORKFLOW=$WORKFLOW" >> "$BASH_ENV"; source "$BASH_ENV" name: Get workflow - run: command: | # shellcheck disable=SC1073 JOB=$( curl --location \ --request GET "https://circleci.com/api/v2/workflow/$WORKFLOW/job" \ -u "$<< parameters.circle_token >>:" \ | jq -r ".items[] | select( .name == \"<< parameters.regression_job >>\" ) | .id" ) echo "export JOB=$JOB" >> "$BASH_ENV"; source "$BASH_ENV" name: Get job - run: command: | curl --request POST \ --url "https://circleci.com/api/v2/workflow/$WORKFLOW/approve/$JOB" \ -u "$<< parameters.circle_token >>:" name: Approve job find_wpe_install: description: Set up our WPE_Install based on the environment parameters: environment: default: undefined description: | Are we deploying to the production, staging, development, or custom environment? Production, staging, and development need a corresponding environment variable defined in CircleCI's project configuration. An optional `./.gitignores/__deployment` file can be used to deploy build files rather than source files. type: string steps: - run: command: | # shellcheck disable=SC2050 if [[ "undefined" == "<< parameters.environment >>" ]]; then WPE_ENV="$CIRCLE_BRANCH" else WPE_ENV="<< parameters.environment >>" fi # Set the destination according to the environment. case "$WPE_ENV" in master) WPE_INSTALL="$WPE_PRODUCTION_INSTALL";; production) WPE_INSTALL="$WPE_PRODUCTION_INSTALL";; staging) WPE_INSTALL="$WPE_STAGING_INSTALL";; *) WPE_INSTALL="$WPE_DEVELOPMENT_INSTALL";; esac # Match any deploy-install pattern and set the install as the destination. if [[ "$CIRCLE_BRANCH" =~ deploy-[a-z][a-z0-9]{2,13} ]]; then WPE_INSTALL="${CIRCLE_BRANCH/deploy-/}" fi echo "export WPE_INSTALL=$WPE_INSTALL" >> "$BASH_ENV" source "$BASH_ENV" name: Set up the WPE install name gitignoreswap: description: | Swaps gitignore file for one that parameters: gitignore_type: default: site description: Type of gitignore file to load enum: - site - package type: enum steps: - run: command: | if [ -f ./.gitignores/__deployment ]; then rm -f .gitignore cp ./.gitignores/__deployment .gitignore else rm -f .gitignore wget -nc -O .gitignore "https://raw.githubusercontent.com/ryanshoover/orb-wpengine-deploy/master/lib/deploy-<< parameters.gitignore_type >>.gitignore" fi name: Swap our gitignore files - run: command: rm -rf wp-content/{mu-plugins,plugins,themes}/*/.git* name: Remove git files from packages to ensure correct deployment. - run: command: git add . name: Add all files for deployment - run: command: git ls-files -c -z --ignored --exclude-standard | xargs -0 git rm -r --force --ignore-unmatch --cached name: After adding all files, remove files that should be ignored - run: command: git commit -m "Deployment commit" name: Commit build files description: | Commands, Executors, and Jobs for testing a WordPress site and for deploying to WP Engine installs. examples: wordpress-plugin: description: | A sample CircleCI config file that uses the ryanshoover/wpengine orb to run lint and codeception on a WordPress plugin. It also deploys tags to a Gemfury repository. usage: orbs: wpengine: ryanshoover/wpengine@x.y.z version: 2.1 workflows: test-deploy: jobs: - wpengine/build - wpengine/lint: requires: - wpengine/build - wpengine/codeception: package_name: my-custom-plugin package_type: plugin requires: - wpengine/build - wpengine/deploy_fury: filters: branches: ignore: /.*/ tags: only: /^\d+\.\d+\.\d+$/ requires: - wpengine/lint - wpengine/codeception version: 2 wordpress-site: description: | A sample CircleCI config file that uses the ryanshoover/wpengine orb to test a site repo at every stage, deploy the site to WP Engine environments, and run regressions on the staging site. usage: orbs: wpengine: ryanshoover/wpengine@x.y.z version: 2.1 workflows: build_test_deploy: jobs: - wpengine/build - wpengine/lint: requires: - wpengine/build - wpengine/codeception: requires: - wpengine/build - wpengine/deploy_site: environment: development filters: branches: only: development name: deploy-development requires: - wpengine/lint - wpengine/codeception - wpengine/deploy_site: environment: staging filters: branches: only: staging name: deploy-staging pipeline_id: << pipeline.id >> regression_enabled: true requires: - wpengine/lint - wpengine/codeception - wpengine/deploy_site: environment: production filters: branches: only: - master - production name: deploy-production pipeline_id: << pipeline.id >> regression_enabled: true requires: - wpengine/lint - wpengine/codeception - wpengine/backup - wpengine/deploy_site: environment: thenameofmyfeatureinstall filters: branches: only: - /feat-.*/ name: deploy-feature requires: - wpengine/lint - wpengine/codeception - wpengine/deploy_site: environment: qa filters: branches: only: - /deploy-.*/ name: deploy-site requires: - wpengine/lint - wpengine/codeception regression: jobs: - wpengine/backstop_reference: config: tests/backstop/ context: DXT filters: branches: only: - staging - master - hold-for-deploy: requires: - wpengine/backstop_reference type: approval - wpengine/backstop_test: config: tests/backstop/ context: DXT requires: - hold-for-deploy version: 2 executors: php: docker: - image: cimg/php:7.4-node jobs: backstop_reference: description: Run visual regression tests using backstopjs docker: - image: backstopjs/backstopjs parameters: config: description: Path to the backstop config file type: string steps: - checkout - run: mkdir -p /tmp/tests/backstop - find_wpe_install - run: command: | backstop reference \ --config="<< parameters.config >>" \ --reports_dir="/tmp/tests/backstop" \ --refurl="https://$WPE_INSTALL.wpengine.com" name: Build reference files pre-deploy - persist_to_workspace: paths: - . root: /tmp/tests backstop_test: description: Run visual regression tests using backstopjs docker: - image: backstopjs/backstopjs parameters: config: description: Path to the backstop config file type: string steps: - attach_workspace: at: /tmp/tests - checkout - find_wpe_install - run: command: | backstop test \ --config="<< parameters.config >>" \ --reports_dir="/tmp/tests/backstop" \ --url="https://$WPE_INSTALL.wpengine.com" name: Test against deployed site - store_artifacts: path: /tmp/tests/backstop - store_test_results: path: /tmp/tests/backstop backup: description: | Generate a backup of production prior to deployment. `yarn run dxt-backup` executor: php steps: - attach_workspace: at: /home/circleci/project - run: command: | yarn run dxt-backup name: Run the backup script. build: description: | Build a plugin, theme, or site. Installs composer and yarn dependencies. Runs yarn build command. executor: php steps: - checkout - restore_cache: keys: - composer-{{ .Environment.CACHE_VERSION }}-{{ checksum "composer.lock" }} - run: command: | if [ -f composer.lock ]; then composer install --no-ansi --no-interaction --no-progress --optimize-autoloader --prefer-dist fi name: Install composer dependencies - save_cache: key: composer-{{ .Environment.CACHE_VERSION }}-{{ checksum "composer.lock" }} paths: - ./vendor - restore_cache: keys: - yarn-{{ .Environment.CACHE_VERSION }}-{{ checksum "yarn.lock" }} - run: command: npm config set @dxt:registry https://npm.fury.io/wpedxt/ name: Add Gemfury registry - run: command: echo "//npm.fury.io/wpedxt/:_authToken=${FURY_AUTH}" > .npmrc name: Add authentication to Gemfury - run: command: | if [ -f yarn.lock ]; then yarn install --emoji false --non-interactive fi name: Install node dependencies - save_cache: key: yarn-{{ .Environment.CACHE_VERSION }}-{{ checksum "yarn.lock" }} paths: - ./node_modules - run: command: | if jq -e '.scripts.build' package.json; then yarn run build fi name: Build compiled files - persist_to_workspace: paths: - . root: /home/circleci/project codeception: description: | Run codeception tests for end-to-end testing on a WordPress site. Codeception supports unit, wpunit, functional, and acceptance testing. docker: - environment: DOCKERIZE_VERSION: v0.6.1 WORDPRESS_ADMIN_EMAIL: admin@wp.local WORDPRESS_ADMIN_PASSWORD: password WORDPRESS_ADMIN_USERNAME: admin WORDPRESS_DB_CHARSET: utf8 WORDPRESS_DB_HOST: mysql WORDPRESS_DB_NAME: wordpress WORDPRESS_DB_PASSWORD: wordpress WORDPRESS_DB_USER: wordpress WORDPRESS_DOMAIN: localhost WORDPRESS_ROOT_FOLDER: /home/circleci/project WORDPRESS_TABLE_PREFIX: wp_ WORDPRESS_URL: http://localhost image: cimg/php:7.4-node - environment: MYSQL_DATABASE: wordpress MYSQL_PASSWORD: wordpress MYSQL_ROOT_PASSWORD: password MYSQL_USER: wordpress image: circleci/mysql:5 name: mysql - image: selenium/standalone-chrome name: webdriver parameters: package_name: default: project description: Name of the plugin or theme (directory name) type: string package_type: default: project description: Is this a WordPress plugin or theme enum: - plugin - theme - project type: enum steps: - run: command: | sudo apt-get update && \ sudo apt-get -y install \ apache2 \ libapache2-mod-php \ php-mysql \ default-mysql-client \ libjpeg-dev \ libpng-dev \ libzip-dev name: Install apt needs - restore_cache: keys: - installwpbrowser-{{ .Environment.CACHE_VERSION }} - run: command: | composer global require --optimize-autoloader \ lucatume/wp-browser \ codeception/module-asserts:^1.0 \ codeception/module-cli:^1.0 \ codeception/module-db:^1.0 \ codeception/module-filesystem:^1.0 \ codeception/module-phpbrowser:^1.0 \ codeception/module-rest:^1.0 \ codeception/module-webdriver:^1.0 \ codeception/util-universalframework \ league/factory-muffin \ league/factory-muffin-faker \ wp-cli/wp-cli-bundle name: Install wp-browser globally - save_cache: key: installwpbrowser-{{ .Environment.CACHE_VERSION }} paths: - ~/.composer - ~/.config/composer - run: command: | COMPOSER_GLOBAL_BIN=$(composer global config bin-dir --absolute --quiet) if ! echo "$PATH" | grep "$COMPOSER_GLOBAL_BIN"; then echo "export PATH=$COMPOSER_GLOBAL_BIN:$PATH" >> "$BASH_ENV" fi name: Add global composer bin-dir to PATH - run: command: | echo "ServerName localhost <Directory ${CIRCLE_WORKING_DIRECTORY}> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory>" | sudo tee -a /etc/apache2/conf-available/localhost.conf > /dev/null echo "<VirtualHost *:80> DocumentRoot ${CIRCLE_WORKING_DIRECTORY} </VirtualHost>" | sudo tee -a /etc/apache2/sites-available/localhost.conf > /dev/null sudo a2enmod rewrite sudo a2enconf localhost sudo a2ensite localhost sudo a2dissite 000-default sudo service apache2 restart name: Set up Apache - run: dockerize -wait "tcp://$WORDPRESS_DB_HOST:3306" -timeout 1m - run: command: echo "export WORDPRESS_DOMAIN=$( hostname -i ); export WORDPRESS_URL=http://$( hostname -i )" >> "$BASH_ENV" name: Set up env variables for codeception testing - when: condition: equal: - project - << parameters.package_type >> steps: - attach_workspace: at: /home/circleci/project - run: command: echo "export CODECEPT_DIRECTORY=$CIRCLE_WORKING_DIRECTORY" >> "$BASH_ENV" name: Set up tests directory - when: condition: or: - equal: - theme - << parameters.package_type >> - equal: - plugin - << parameters.package_type >> steps: - attach_workspace: at: /home/circleci/project/wp-content/<< parameters.package_type >>s/<< parameters.package_name >> - run: command: echo "export CODECEPT_DIRECTORY=$CIRCLE_WORKING_DIRECTORY/wp-content/<< parameters.package_type >>s/<< parameters.package_name >>" >> "$BASH_ENV" name: Set up tests directory - run: command: wp core download name: Download WordPress - run: command: | echo '# BEGIN WordPress RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] # END WordPress' | tee -a .htaccess > /dev/null name: Create htaccess file - run: command: | wp config create \ --dbname="$WORDPRESS_DB_NAME" \ --dbuser="$WORDPRESS_DB_USER" \ --dbpass="$WORDPRESS_DB_PASSWORD" \ --dbhost="$WORDPRESS_DB_HOST" \ --dbprefix="$WORDPRESS_TABLE_PREFIX" \ --dbcharset="$WORDPRESS_DB_CHARSET" \ --skip-check name: Config WordPress - run: command: | wp core install \ --url="$WORDPRESS_URL" \ --title="Test" \ --admin_user="$WORDPRESS_ADMIN_USERNAME" \ --admin_password="$WORDPRESS_ADMIN_PASSWORD" \ --admin_email="$WORDPRESS_ADMIN_EMAIL" name: Install WordPress - run: command: | mkdir -p wp-content/mu-plugins mkdir -p wp-content/plugins mkdir -p wp-content/themes chmod a+rx wp-content wp-content/plugins wp-content/themes wp-content/uploads wp db export wp-content/mysql.sql \ --skip-plugins \ --skip-themes \ --allow-root name: Export a database dump - run: touch "$CODECEPT_DIRECTORY/.env" - run: command: wget -nc -P "$CODECEPT_DIRECTORY" https://raw.githubusercontent.com/ryanshoover/orb-wpengine-deploy/master/lib/codeception.dist.yml name: Download codeception dist files - run: command: | if [ -d "$CODECEPT_DIRECTORY/vendor/wpengine/dxt-tester/lib/codecept" ]; then mv "$CODECEPT_DIRECTORY/vendor/wpengine/dxt-tester/lib/codecept" "$CODECEPT_DIRECTORY" fi name: Maybe move dxt-tester files - run: command: cd "$CODECEPT_DIRECTORY" && codecept run acceptance --xml="$CIRCLE_WORKING_DIRECTORY/test-results/acceptance/results.xml" --no-interaction name: Run Codeception acceptance tests - run: command: cd "$CODECEPT_DIRECTORY" && codecept run functional --xml="$CIRCLE_WORKING_DIRECTORY/test-results/functional/results.xml" --no-interaction name: Run Codeception functional tests - run: command: cd "$CODECEPT_DIRECTORY" && codecept run unit --xml="$CIRCLE_WORKING_DIRECTORY/test-results/unit/results.xml" --no-interaction name: Run Codeception unit tests - run: command: cd "$CODECEPT_DIRECTORY" && codecept run wpunit --xml="$CIRCLE_WORKING_DIRECTORY/test-results/wpunit/results.xml" --no-interaction name: Run Codeception wpunit tests - store_test_results: path: test-results - store_artifacts: path: test-results working_directory: /home/circleci/project deploy_fury: description: | Deploy a PHP, Node, or Ruby package to a Gemfury repository. Designed to be run on new GitHub releases. executor: php parameters: project: default: CIRCLE_PROJECT_REPONAME description: Project name type: env_var_name token: default: GEMFURY_TOKEN_PUSH description: Gemfury PUSH token type: env_var_name user: default: GEMFURY_USER description: Gemfury user or team name type: env_var_name steps: - attach_workspace: at: /home/circleci/project - run: command: | git config --global user.email "deploy@circleci.local" git config --global user.name "$CIRCLE_PROJECT_REPONAME" name: Set up git - run: command: git remote add fury "https://$<< parameters.user >>:$<< parameters.token >>@git.fury.io/$<< parameters.user >>/$<< parameters.project >>.git" name: Add Fury git repo - run: command: git checkout master name: Check out master branch - run: command: | if [ -f composer.lock ]; then composer install --no-dev --no-ansi --no-interaction --no-progress --optimize-autoloader --prefer-dist fi name: Install production composer dependencies - run: command: | if [ -f yarn.lock ]; then npm prune --production fi name: Install production yarn dependencies - gitignoreswap: gitignore_type: package - run: command: | if [[ ! -z "${CIRCLE_TAG}" ]]; then git tag -f -m "Fury deployment compiled" "$CIRCLE_TAG" fi name: Rewrite tag with compiled files - deploy: command: git push fury master --tags --force name: Deploy to GemFury deploy_pr: description: | Create deploy pull requests, `Staging ← Development` and `Master ← Staging` docker: - image: cimg/base:stable parameters: target: description: Target branch to be the PR base type: string steps: - checkout - run: command: | curl -s https://api.github.com/repos/cli/cli/releases/latest \ | grep browser_download_url \ | grep linux_amd64.deb \ | cut -d '"' -f 4 \ | wget -qi - sudo apt install ./gh_*_linux_amd64.deb name: Install GH CLI - run: command: | mkdir -p ~/.config/gh { echo "hosts:" echo " github.com:" echo " oauth_token: $GITHUB_OAUTH_TOKEN" echo " user: $GITHUB_OAUTH_USER" } >> ~/.config/gh/config.yml name: Configure GH CLI - run: command: | gh pr close "$( gh pr list --repo="$CIRCLE_PROJECT_REPONAME" --base="$TARGET_BRANCH" | grep -o "^[[:digit:]]*" )" exit 0 # always succeed, even if there's not a PR to close name: Get existing PR number - run: command: | PR_BODY="" PR_URLS=$(echo "$CIRCLE_PULL_REQUESTS" | tr "," "\n") for PR_URL in $PR_URLS; do [ -z "$PR_URL" ] && continue; PR_URL_BODY="$( gh pr view "$PR_URL" )" TITLE="" INCLUDE=0 for LINE in $PR_URL_BODY; do [[ -z "$TITLE" && $LINE =~ ^[[:space:]] ]] && TITLE="$( echo "$LINE" | xargs )" && PR_BODY="$PR_BODY\n$TITLE" LINE="$( echo "$LINE" | xargs )" [[ $LINE =~ "^#" ]] && INCLUDE=0 [[ "## Deploy Notes" == "$LINE" || "## Steps to Test or Reproduce" == "$LINE" ]] && INCLUDE=1 [[ $INCLUDE = 1 ]] && PR_BODY="$PR_BODY\n$LINE" done PR_BODY="$PR_BODY\n" done echo "export PR_BODY" >> "$BASH_ENV" name: Compile PR body - deploy: command: | gh pr create \ --base=<< parameters.target >> \ --title="<< parameters.target >> ← $CIRCLE_BRANCH" \ --body="$BODY" name: Create PR deploy_site: description: Build and deploy the codebase to a WP Engine environment executor: php parameters: environment: description: | Are we deploying to the production, staging, development, or custom environment? Production, staging, and development need a corresponding environment variable defined in CircleCI's project configuration. An optional `./.gitignores/__deployment` file can be used to deploy build files rather than source files. type: string pipeline_id: default: 00000000-0000-0000-0000-000000000001 description: Pipeline ID from the job. The orb can't access the ID directly for security reasons type: string regression_enabled: default: false description: | Should we try to approve a regression workflow? If you have a regression workflow that runs in parallel to your deploy workflows, set this to be true. The regression workflow's "hold for approval" job will be approved once the deploy finishes. type: boolean regression_job: default: hold-for-deploy description: Name of the job that needs approved type: string regression_workflow: default: regression description: Name of the regression workflow that needs approved type: string rollbar_token: default: ROLLBAR_ACCESS_TOKEN description: API token for accessing Rollbar type: env_var_name steps: - attach_workspace: at: /home/circleci/project - run: command: | if [ -f composer.lock ]; then composer install --no-dev --no-ansi --no-interaction --no-progress --optimize-autoloader --prefer-dist fi name: Install production composer dependencies - run: command: | if [ -f yarn.lock ]; then npm prune --production fi name: Install production yarn dependencies - run: command: mkdir -p ~/.ssh && ssh-keyscan -t rsa -H git.wpengine.com >> ~/.ssh/known_hosts name: Add deploy host to known_hosts - find_wpe_install: environment: << parameters.environment >> - run: command: | git config --global user.email "deploy@circleci.local" git config --global user.name "$CIRCLE_PROJECT_REPONAME" git remote add wpe "git@git.wpengine.com:production/${WPE_INSTALL}.git" git fetch wpe name: Set up the WP Engine install git remotes - run: command: git checkout -b "${CIRCLE_BRANCH}-${CIRCLE_BUILD_NUM}" name: Check out a new branch - gitignoreswap: gitignore_type: site - when: condition: << parameters.rollbar_token >> steps: - rollbar/notify_deploy_started: environment: << parameters.environment >> - deploy: command: | git push wpe "${CIRCLE_BRANCH}-${CIRCLE_BUILD_NUM}" git push wpe ":${CIRCLE_BRANCH}-${CIRCLE_BUILD_NUM}" name: Push to WPE environment - when: condition: << parameters.rollbar_token >> steps: - rollbar/notify_deploy_finished: deploy_id: ${ROLLBAR_DEPLOY_ID} status: succeeded - when: condition: << parameters.regression_enabled >> steps: - approve_hold_for_deploy: pipeline_id: << parameters.pipeline_id >> regression_job: << parameters.regression_job >> regression_workflow: << parameters.regression_workflow >> lint: description: | Lint the files to make sure everything follows best practices. `yarn run lint` can be a combination of phpcs, jslint, sass-lint, and more executor: php steps: - attach_workspace: at: /home/circleci/project - run: command: | if jq -e '.scripts.lint' composer.json; then composer run lint fi name: Run composer lint - run: command: | if jq -e '.scripts.lint' package.json; then yarn run lint fi name: Run yarn lint orbs: rollbar: rollbar/deploy@1.0.1 version: 2.1
Developer Updates
Get tips to optimize your builds
Or join our research panel and give feedback
By submitting this form, you are agreeing to ourTerms of UseandPrivacy Policy.