Browse Source

👷 Add netlify deployment steps

pull/1/head
anthony 5 years ago
parent
commit
8250fa90e2
  1. 163
      .circleci/config.yml

163
.circleci/config.yml

@ -0,0 +1,163 @@
version: 2.1
# --- Constants --- #
globals:
images:
node: &node cimg/node:lts
caches:
dependencies: &dependencies dependencies-{{ checksum "package.json" }}
docker_hub:
user-id: &dockerhub-user-id anthonyjhoiro
password: &dockerhub-password $DOCKERHUB_PASSWORD
image: &dockerhub-image devops-tpfinal-front
# --- Commands --- #
commands:
setup_dependencies:
description: Setup the environment
steps:
- checkout
- restore_cache:
keys:
- *dependencies
# --- Jobs definitions --- #
jobs:
build: &shared-config
docker:
- image: *node
auth:
username: *dockerhub-user-id
password: *dockerhub-password
working_directory: ~/app
steps:
- checkout
- restore_cache:
keys:
- *dependencies
# fallback to using the latest cache if no exact match is found
- dependencies-
- run: yarn install
- save_cache:
paths:
- node_modules
key: *dependencies
test:
<<: *shared-config
steps:
- setup_dependencies
- run: yarn test:unit
lint:
<<: *shared-config
steps:
- setup_dependencies
- run:
name: Check files format
command: yarn format:check
- run:
name: Lint files
command: yarn lint
docker-build:
<<: *shared-config
environment:
DOCKER_HUB_PWD: *dockerhub-password
DOCKER_HUB_USER_ID: *dockerhub-user-id
DOCKER_HUB_IMAGE: *dockerhub-image
steps:
- checkout
- setup_remote_docker:
version: 20.10.7
- run:
name: Build docker image
command: |
echo true
#docker build -t app .
- deploy:
name: Publish image to Docker Hub
command: |
echo true
#echo $DOCKERHUB_PASSWORD | docker login -u $DOCKER_HUB_USER_ID --password-stdin
#docker tag app $DOCKER_HUB_USER_ID/$DOCKER_HUB_IMAGE:$CIRCLE_BUILD_NUM
#docker tag app $DOCKER_HUB_USER_ID/$DOCKER_HUB_IMAGE:latest
#docker push $DOCKER_HUB_USER_ID/$DOCKER_HUB_IMAGE:$CIRCLE_BUILD_NUM
#docker push $DOCKER_HUB_USER_ID/$DOCKER_HUB_IMAGE:latest
build-netlify:
<<: *shared-config
environment:
VITE_BACKEND_URL_URL: https://tpfinal-devops-back.herokuapp.com/
steps:
- setup_dependencies
- run: yarn build
- run:
name: Copy deployment artifacts to workspace
command: |
cp -r dist/ /tmp/build
- store_artifacts:
path: /tmp/build
- persist_to_workspace:
root: /tmp
paths:
- build
deploy-netlify:
<<: *shared-config
working_directory: ~/todoapp
steps:
- attach_workspace:
at: /tmp
- run:
name: Install netlify
command: yarn add -D netlify-cli
- run:
name: Deploy app
command: yarn netlify deploy --prod --dir=/tmp/build
# --- Workflow definition --- #
workflows:
version: 2
build-test-and-lint:
jobs:
- build
- test:
requires:
- build
- lint:
requires:
- build
- build-netlify:
requires:
- test
- lint
filters:
branches:
only:
- main
- deploy-netlify:
requires:
- build-netlify
filters:
branches:
only:
- main
- docker-build:
requires:
- test
- lint
filters:
branches:
only:
- main
Loading…
Cancel
Save