How to use bitbucket pipelines to deploy to WPEngine

THE PROBLEM

MY SOLUTION

dep: &dep
step:
name: Installing dependencies
caches:
- node
script:
- npm cache clean -f
- npm install -g n
- npm install -g gulp-cli
- yarn
build: &build
step:
name: Build assets
caches:
- node
script:
- apt-get update -y
- apt-get install -y ssh
- apt-get install -y zip
- npm rebuild node-sass
- npm run build
- zip -r temp.zip wp-content
artifacts:
- temp.zip
deploy: &deploy
step:
name: Deploy to PROD
script:
- export REPO="your_repo.git"
- export USER_EMAIL="$USER_EMAIL"
- export USER_NAME="$USER_NAME"
- echo deploying to $REPO
- rm -rf .git
- git config --global user.email "$USER_EMAIL"
- git config --global user.name "$USER_NAME"
- git clone git@git.wpengine.com:production/$REPO deploy
- mv temp.zip deploy/ && cd deploy
- ls | grep -v temp.zip | xargs rm -rf
- unzip temp.zip
- git status
- git add . && git commit -m "$BITBUCKET_COMMIT"
- git push origin master
- git push -f git@git.wpengine.com:staging/$REPO master
pipelines:
branches:
'master':
- <<: *dep
- <<: *build
- <<: *deploy

TL;DR;

image:
name: node:10.24.1

dep: &dep
step:
name: Installing dependencies
caches:
- node
script:
- npm cache clean -f
- npm install -g n
- npm install -g gulp-cli
- yarn

build: &build
step:
name: Build assets
caches:
- node
script:
- apt-get update -y
- apt-get install -y ssh
- apt-get install -y zip
- npm rebuild node-sass
- npm run build
- zip -r temp.zip wp-content
artifacts:
- temp.zip

deploy: &deploy
step:
name: Deploy to WP Engine
script:
- export REPO="your_repo.git"
- export USER_EMAIL="$USER_EMAIL"
- export USER_NAME="$USER_NAME"
- echo deploying to $REPO
- rm -rf .git
- git config --global user.email "$USER_EMAIL"
- git config --global user.name "$USER_NAME"
- git clone git@git.wpengine.com:production/$REPO deploy
- mv temp.zip deploy/ && cd deploy
- ls | grep -v temp.zip | xargs rm -rf
- unzip temp.zip
- git status
- git add . && git commit -m "$BITBUCKET_COMMIT"
- git push origin master
- git push -f git@git.wpengine.com:staging/$REPO master

pipelines:
branches:

'master':
- <<: *dep
- <<: *build
- <<: *deploy

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store