Last active
October 15, 2018 20:40
CircleCI - Hangouts Chat Notifications
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: 2 | |
jobs: | |
deploy: | |
docker: | |
# little bit tuned node image with git & curl | |
- image: ifenerji/node-alpine-git:latest | |
working_directory: ~/repo | |
steps: | |
- checkout | |
- run: | |
name: Install global dependencies | |
command: 'npm install -g parcel-bundler gulp karma-cli netlify-cli' | |
# Download and cache dependencies | |
- restore_cache: | |
keys: | |
- v1-dependencies-{{ checksum "package.json" }} | |
# fallback to using the latest cache if no exact match is found | |
- v1-dependencies- | |
- run: | |
name: Install dependencies | |
command: yarn install --ignore-scripts | |
- save_cache: | |
paths: | |
- node_modules | |
key: v1-dependencies-{{ checksum "package.json" }} | |
# run tests! | |
- run: yarn test | |
- run: | |
name: Build | |
command: yarn build | |
- deploy: | |
name: Deploy | |
command: yarn deploy | |
- run: | |
name: Chat Notification Fail | |
when: on_fail | |
command: > | |
curl --header "Content-Type: application/json" | |
--request POST | |
--data "{\"cards\":[{\"header\":{\"title\":\"Oops. Build ${CIRCLE_BUILD_NUM} failed.\",\"subtitle\":\"${CIRCLE_PROJECT_REPONAME}\",\"imageUrl\":\"https://png.pngtree.com/svg/20170406/icon_failed__1325447.png\",\"imageStyle\":\"IMAGE\"},\"sections\":[{\"widgets\":[{\"keyValue\":{\"topLabel\":\"${CIRCLE_TAG}\",\"content\":\"${CIRCLE_SHA1}\"}}]},{\"widgets\":[{\"buttons\":[{\"textButton\":{\"text\":\"DETAILS\",\"onClick\":{\"openLink\":{\"url\":\"${CIRCLE_BUILD_URL}\"}}}}]}]}]}]}" | |
$CHAT_WEBHOOK_URL | |
- run: | |
name: Chat Notification Success | |
when: on_success | |
command: > | |
curl --header "Content-Type: application/json" | |
--request POST | |
--data "{\"cards\":[{\"header\":{\"title\":\"Build ${CIRCLE_BUILD_NUM} passed.\",\"subtitle\":\"${CIRCLE_PROJECT_REPONAME}\",\"imageUrl\":\"https://png.pngtree.com/svg/20170510/success_404253.png\",\"imageStyle\":\"IMAGE\"},\"sections\":[{\"widgets\":[{\"keyValue\":{\"topLabel\":\"${CIRCLE_TAG}\",\"content\":\"${CIRCLE_SHA1}\"}}]},{\"widgets\":[{\"buttons\":[{\"textButton\":{\"text\":\"DETAILS\",\"onClick\":{\"openLink\":{\"url\":\"${CIRCLE_BUILD_URL}\"}}}}]}]}]}]}" | |
$CHAT_WEBHOOK_URL | |
workflows: | |
version: 2 | |
build-n-deploy: | |
jobs: | |
- deploy: | |
filters: | |
branches: | |
only: do-not-build | |
tags: | |
only: /[0-9]+(\.[0-9]+)*(-\w*)*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment