Skip to content

Instantly share code, notes, and snippets.

@Yloganathan
Last active May 21, 2019 00:20
Show Gist options
  • Save Yloganathan/3a2ec9826f06af279adf75abf31c4ef8 to your computer and use it in GitHub Desktop.
Save Yloganathan/3a2ec9826f06af279adf75abf31c4ef8 to your computer and use it in GitHub Desktop.
Sample circleci config
version: 2.1
executors:
python-executor:
docker:
- image: circleci/python:3.7.2
working_directory: /home/circleci/project
jobs:
test:
executor: python-executor
steps:
- checkout
- run:
name: install dependencies
environment:
PIPENV_NOSPIN: 1
PIPENV_VENV_IN_PROJECT: 1
command: |
pipenv sync --dev
mkdir -p test-data/project
- run:
name: lint
command: pipenv run flake8
- run:
name: run tests
command: |
pipenv run pytest --cov=project -v --junitxml=test-data/project/junit.xml
- store_test_results:
path: test-data
- store_artifacts:
path: test-data
- persist_to_workspace:
root: /home/circleci/
paths:
- project
build:
executor: python-executor
steps:
- attach_workspace:
at: /home/circleci
- run:
name: AWS configure
command: |
pipenv run aws configure set aws_access_key_id $AWS_ACCESS_KEY
pipenv run aws configure set aws_secret_access_key $AWS_SECRET_KEY
cp .circleci/aws_config ~/.aws/config
- run:
name: Docker Image
command: |
$(pipenv run aws ecr get-login --no-include-email --region $AWS_DEFAULT_REGION --profile bprod)
docker build -t $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$AWS_ECR_REPONAME:$latest .
docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$AWS_ECR_REPONAME:$latest
- persist_to_workspace:
root: /home/circleci/
paths:
- project
- .aws
deploy: &deploy
executor: python-executor
steps:
- attach_workspace:
at: /home/circleci
- run:
name: deploy fargate
command: |
pipenv run python deploy/promote.py $ENVIRONMENT $AWS_PROFILE
deploy_to_dev:
<<: *deploy
deploy_to_uat:
<<: *deploy
deploy_to_prod:
<<: *deploy
workflows:
version: 2
test-build-deploy:
jobs:
- test
- build:
requires:
- test
context: org-global
- deploy_to_dev:
requires:
- build
context: dev
filters:
branches:
only: master
- deploy_to_uat:
requires:
- deploy_to_dev
context: uat
- hold:
type: approval
requires:
- deploy_to_uat
- deploy_to_prod:
requires:
- hold
context: production
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment