Skip to content

Commit

Permalink
[#106] Refactor circleci config to remove deploy steps
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaPrete committed Apr 17, 2020
1 parent 935fdba commit f5d5dea
Showing 1 changed file with 28 additions and 118 deletions.
146 changes: 28 additions & 118 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,134 +1,44 @@
# Javascript Node CircleCI 2.1 configuration file
## Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2.1
executors:
docker-publisher:
environment:
IMAGE_NAME: italia/developers-italia-onboarding
docker:
- image: circleci/buildpack-deps:stretch
jobs:
build:
# Check https://circleci.com/docs/2.0/ for more details

references:
working_directory: /tmp/onboarding

load_image: &load_image
docker:
- image: circleci/node:lts

working_directory: ~/repo
steps:
- checkout
- run:
name: npm install
command: npm install
- run:
name: npm lint
command: npm run lint
docker-build-prod:
executor: docker-publisher
steps:
- checkout
- setup_remote_docker
- run:
name: Build Docker image
command: |
docker build -t $IMAGE_NAME:latest .
- run:
name: Archive Docker image
command: docker save -o $IMAGE_NAME_PROD $IMAGE_NAME
- persist_to_workspace:
root: .
paths:
- ./*.tar
docker-build-dev:
executor: docker-publisher
install_dependencies: &install_dependencies
run:
name: npm-install
command: |
npm install
lint: &lint
run:
name: lint
command: |
npm run lint
version: 2
jobs:
test:
<<: *load_image
steps:
- checkout
- setup_remote_docker
- run:
name: Build Docker image
command: |
docker build -t $IMAGE_NAME:development .
- run:
name: Archive Docker image
command: docker save -o $IMAGE_NAME_DEV $IMAGE_NAME
- persist_to_workspace:
root: .
paths:
- ./*.tar
deploy-prod:
machine:
enabled: true
steps:
- attach_workspace:
at: /tmp/workspace
- run: rsync -avz /tmp/workspace/$IMAGE_NAME_PROD circleci@$SSH_HOST:/tmp/$IMAGE_NAME_PROD
- run:
name: deploy on prod
command: |
ssh circleci@$SSH_HOST $SSH_COMMAND_PROD
deploy-dev:
machine:
enabled: true
steps:
- attach_workspace:
at: /tmp/workspace
- run: rsync -avz /tmp/workspace/$IMAGE_NAME_DEV circleci@$SSH_HOST:/tmp/$IMAGE_NAME_DEV
- run:
name: deploy on dev
command: |
ssh circleci@$SSH_HOST $SSH_COMMAND_DEV
- << : *install_dependencies
- << : *lint

workflows:
version: 2
# For any branch other than master,
# run CI tests at each commit
on-commit-test:
jobs:
- build:
- test:
filters:
branches:
ignore:
- development
- master
on-commit-build-and-deploy_prod:
jobs:
- build:
filters:
branches:
only:
- master
- docker-build-prod:
requires:
- build
filters:
branches:
only:
- master
- deploy-prod:
requires:
- build
- docker-build-prod
filters:
branches:
only:
- master
on-commit-build-and-deploy_dev:
jobs:
- build:
filters:
branches:
only:
- development
- docker-build-dev:
requires:
- build
filters:
branches:
only:
- development
- deploy-dev:
requires:
- build
- docker-build-dev
filters:
branches:
only:
- development

0 comments on commit f5d5dea

Please sign in to comment.