Skip to content

Instantly share code, notes, and snippets.

@acidjazz
Created January 19, 2019 18:03
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 acidjazz/7155b842db0a886b620b85a5ebf6845a to your computer and use it in GitHub Desktop.
Save acidjazz/7155b842db0a886b620b85a5ebf6845a to your computer and use it in GitHub Desktop.
circleci config for a https://github.com/acidjazz/laranuxt project
version: 2
jobs:
build:
docker:
- image: circleci/php:7-node-browsers-legacy
environment:
PIPENV_VENV_IN_PROJECT: true
- image: circleci/python:3.6.4
- image: circleci/mysql:5.7
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_ROOT_PASSWORD: ''
MYSQL_DATABASE: mahalo
working_directory: ~/mahalo
steps:
- run:
name: apt packages needed, libgmp
command: sudo apt install libgmp-dev
- run:
name: Install pdo and gmp for PHP
command: sudo docker-php-ext-install pdo_mysql gmp
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "composer.json" }}-{{ checksum "package.json" }}
- v1-dependencies-
- run:
name: Install pip and awscli
command: |
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py --user
~/.local/bin/pip install awscli --upgrade --user
- run:
name: Install dependencies with composer
command: composer install -n --prefer-dist
- save_cache:
key: v1-dependencies-{{ checksum "composer.json" }}-{{ checksum "package.json" }}
paths:
- vendor
- node_modules
- .local
- run:
name: Copy over .env.testing
command: cp .env.testing .env
- run:
name: Initial table creation
command: ./artisan migrate --env=testing
- run:
name: Run PHPUnit
command: vendor/bin/phpunit --testdox
- deploy:
name: Deploy code via SSM
command: |
if [ "${CIRCLE_BRANCH}" = 'master' ] || [ "${CIRCLE_BRANCH}" = 'staging' ]; then
commandId=$(~/.local/bin/aws ssm send-command \
--region us-east-1 \
--instance-ids "i-03bd00c9cd7041368" \
--document-name "AWS-RunShellScript" \
--comment "Deploy Web to ${CIRCLE_BRANCH}" \
--parameters '{"commands": ["su - ec2-user -c \"cd ~/mahalo; yarn '"${CIRCLE_BRANCH}"' \""]}' \
--output text \
--query "Command.CommandId")
status="InProgress"
echo ["$commandId"] Status: "$status"
while [ "$status" = InProgress ]
do
status=$(~/.local/bin/aws ssm list-commands \
--region=us-east-1 \
--command-id "$commandId" \
--query "Commands[*].Status" \
| tr -cd '[:alpha:]')
printf .
done
echo
echo ["$commandId"] Status: "$status"
~/.local/bin/aws ssm list-command-invocations \
--region=us-east-1 \
--command-id "$commandId" \
--query="CommandInvocations[*].CommandPlugins[*].Output" \
--details \
| sed 1,2d | sed "s/^[ \t]*\"//" | sed 's/\\n/\'$'\n/g' | head -n -3
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment