From a9c3b8f1092ad5d41000d2e87445fa452b473fea Mon Sep 17 00:00:00 2001 From: Jonatan Castro Date: Thu, 26 Nov 2020 17:24:32 +1100 Subject: [PATCH] SSL Checker: Add custom domains to check + circle configuration --- .circleci/config.yml | 33 +++++++++++++++++++++++++++++++++ .circleci/slack-message.sh | 34 ++++++++++++++++++++++++++++++++++ hosts_to_check | 17 +++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 .circleci/config.yml create mode 100755 .circleci/slack-message.sh create mode 100644 hosts_to_check diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..5c8368a --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,33 @@ +version: 2 +jobs: + backup: + docker: + - image: circleci/python:3.8.0-node + working_directory: ~/repo + steps: + - checkout + - run: + name: Check SSL Certificates + command: | + DATE=`date "+%Y%m%d-%H%M"` + .circleci/slack-message.sh "*Checking SSL Certificates*: Begin" "MASTER" $DATE "#ffff00" + docker build -t ssl-checker . + docker run -it --rm -v $(pwd):/data ssl-checker -f /data/hosts_to_check + .circleci/slack-message.sh "*Checked SSL Certificates*: Finished :key:" "MASTER" $DATE "#008000" + +workflows: + version: 2 + backup: + triggers: + - schedule: + cron: "0 22 * * 1" + filters: + branches: + only: + - master + jobs: + - backup: + context: github-backup + filters: + branches: + only: master diff --git a/.circleci/slack-message.sh b/.circleci/slack-message.sh new file mode 100755 index 0000000..6eeabad --- /dev/null +++ b/.circleci/slack-message.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +set -xue + +DEFAULT_TEXT=$1 +DEPLOY_ENV=${2:-DEV} +VERSION_NUMBER=$3 +COLOR=$4 + +COMMIT_MSG="$(git rev-list --format=%B --max-count=1 $CIRCLE_SHA1)" +TS=$(date +"%s") + +SLACK_MESSAGE='{ + "text": "'$DEFAULT_TEXT'", + "attachments": [ + { + "text":"*Version:* '$VERSION_NUMBER'\n*Environment:* '$DEPLOY_ENV'", + "color":"'$COLOR'" + }, + { + "title": "Commits", + "color":"'$COLOR'", + "title_link": "'$CIRCLE_COMPARE_URL'", + "text": "'$COMMIT_MSG'", + "author_name": "'$CIRCLE_USERNAME'", + "author_link":"https://github.com/'$CIRCLE_USERNAME'", + "author_icon":"https://avatars.githubusercontent.com/'$CIRCLE_USERNAME'", + "footer":"", + "ts": '$TS' + } + ] +}' + +curl -X POST -H 'Content-Type: application/json' --data "$SLACK_MESSAGE" $SLACK_HOOK_URL \ No newline at end of file diff --git a/hosts_to_check b/hosts_to_check new file mode 100644 index 0000000..aaee932 --- /dev/null +++ b/hosts_to_check @@ -0,0 +1,17 @@ +test.rivalbet.com.au +get.rivalbet.com.au +ios.rivalbet.com.au +android.rivalbet.com.au +mobile-web.rivalbet.com.au +app.rivalbet.com.au +app.dev.rivalbet.com.au +get.dev.rivalbet.com.au +ios.dev.rivalbet.com.au +android.dev.rivalbet.com.au +admin-dashboard.rivalbet.com.au +admin-dashboard.dev.rivalbet.com.au +rvlbt.com +scraper.dev.rivalbet.com.au +scraper.prod.rivalbet.com.au +rivaltar.prod.rivalbet.com.au +rivaltar.dev.rivalbet.com.au