Skip to content

Instantly share code, notes, and snippets.

@adriandmitroca
Last active February 20, 2020 10:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adriandmitroca/2924dc49e79affb41030cb2067203520 to your computer and use it in GitHub Desktop.
Save adriandmitroca/2924dc49e79affb41030cb2067203520 to your computer and use it in GitHub Desktop.
CircleCI Deployment Recipe with assets building (Yarn with cache support) & git-ftp
version: 2
jobs:
build:
docker:
- image: circleci/php:7.2-node-browsers
working_directory: ~/repo
steps:
- checkout
- run: sudo apt update && sudo apt install libpng-dev
- run: sudo rm -rf git-ftp && git clone https://github.com/git-ftp/git-ftp.git && cd git-ftp && tag="$(git tag | grep '^[0-9]*\.[0-9]*\.[0-9]*$' | tail -1)" && git checkout "$tag" && sudo make install
- restore_cache:
keys:
- node-v1-{{ checksum "package.json" }}
- node-v1-
- run: yarn install
- save_cache:
key: node-v1-{{ checksum "package.json" }}
paths:
- node_modules
- ~/.yarn
- run: yarn lint
- run: yarn prod
- deploy:
command: |
git reset --hard
if [ "${CIRCLE_BRANCH}" == "staging" ]; then
git ftp push --auto-init -u ${FTP_USERNAME_STAGING} -p ${FTP_PASS_STAGING} -v ftp://YOUR-HOSTNAME.com/wp-content/themes/mimeeq
elif [ "${CIRCLE_BRANCH}" == "master" ]; then
git ftp push --auto-init -u ${FTP_USERNAME_PROD} -p ${FTP_PASS_PROD} -v ftp://YOUR-HOSTNAME.com/wp-content/themes/mimeeq
fi
workflows:
version: 2
build-deploy:
jobs:
- build:
filters:
branches:
only:
- master
- staging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment