extension-workshop/.circleci/config.yml

115 строки
4.1 KiB
YAML

version: 2.0
jobs:
build:
docker:
- image: circleci/ruby:2.6
working_directory: ~/extension-workshop
steps:
- checkout
- restore_cache:
keys:
- rubygems-v1-{{ checksum "Gemfile.lock" }}
- rubygems-v1-fallback
- run:
name: Bundle Install
command: bundle check || bundle install
- save_cache:
key: rubygems-v1-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
- run:
name: yarn install
command: |
sudo apt-get update && sudo apt-get install -y apt-transport-https
sudo apt-get install -y gcc g++ make
# install nodejs v10
# https://github.com/nodesource/distributions/blob/master/README.md#installation-instructions
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
# install yarn stable
# https://yarnpkg.com/lang/en/docs/install/#debian-stable
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install -y yarn
yarn install
- run:
name: test
command: yarn run test
- run:
name: Jekyll build
environment:
JEKYLL_ENV: production
SVGO_BIN: node_modules/svgo/bin/svgo
command: bundle exec jekyll build
- persist_to_workspace:
root: ./
paths:
- ./*
deploy:
docker:
- image: circleci/python:3.7
steps:
- attach_workspace:
at: .
- run:
name: Install AWS CLI
command: |
sudo pip install --upgrade pip
sudo pip install --upgrade awscli
- run:
name: extension workshop deployment
command: |
if [ "$CIRCLE_BRANCH" == "master" ] ; then
# push master branch to -dev env per
# https://github.com/mozilla/extension-workshop/issues/131
AWS_ACCESS_KEY_ID="${DEV_AWS_ACCESS_KEY_ID}" \
AWS_SECRET_ACCESS_KEY="${DEV_AWS_SECRET_ACCESS_KEY}" \
DISTRIBUTION_ID="${DEV_DISTRIBUTION_ID}" \
EXTENSION_WORKSHOP_BUCKET="${DEV_EXTENSION_WORKSHOP_BUCKET}" \
./.utils/deploy.sh
AWS_ACCESS_KEY_ID="${DEV_AWS_ACCESS_KEY_ID}" \
AWS_SECRET_ACCESS_KEY="${DEV_AWS_SECRET_ACCESS_KEY}" \
DISTRIBUTION_ID="${DEV_DISTRIBUTION_ID}" \
EXTENSION_WORKSHOP_BUCKET="${DEV_EXTENSION_WORKSHOP_BUCKET}" \
./.utils/circleci/invalidate-cloudfront-cache.sh
# push master branch to -stage env per
# https://github.com/mozilla/extension-workshop/issues/42
AWS_ACCESS_KEY_ID="${STAGE_AWS_ACCESS_KEY_ID}" \
AWS_SECRET_ACCESS_KEY="${STAGE_AWS_SECRET_ACCESS_KEY}" \
DISTRIBUTION_ID="${STAGE_DISTRIBUTION_ID}" \
EXTENSION_WORKSHOP_BUCKET="${STAGE_EXTENSION_WORKSHOP_BUCKET}" \
./.utils/deploy.sh
AWS_ACCESS_KEY_ID="${STAGE_AWS_ACCESS_KEY_ID}" \
AWS_SECRET_ACCESS_KEY="${STAGE_AWS_SECRET_ACCESS_KEY}" \
DISTRIBUTION_ID="${STAGE_DISTRIBUTION_ID}" \
EXTENSION_WORKSHOP_BUCKET="${STAGE_EXTENSION_WORKSHOP_BUCKET}" \
./.utils/circleci/invalidate-cloudfront-cache.sh
else
./.utils/deploy.sh
./.utils/circleci/invalidate-cloudfront-cache.sh
fi
workflows:
version: 2
build-test-and-deploy:
jobs:
- build:
filters:
tags:
only: /^v?[0-9]+(\.[0-9]+)*$/
- deploy:
requires:
- build
filters:
branches:
only: master
tags:
only: /^v?[0-9]+(\.[0-9]+)*$/