Code Monkey home page Code Monkey logo

analytics.ct.gov-deployment's Introduction

analytics.ct.gov Deployment Scripts

This is the main repository for deploying the project. It contains the scripts necessary to deploy analytics.ct.gov to CT’s servers.

Setting up .env and key.json file

  1. Follow the setup instructions on Analytics-reporter setup instructions
  2. Create a file called key.json inside of the tasks\analytics-reporter\ folder and add the API keys that were collected from Google apis as described in Analytics-reporter setup instructions.
  3. Create a file called .env inside of the tasks\analytics-reporter\ folder add the following variables as described in Analytics-reporter setup instructions.
    export ANALYTICS_REPORT_EMAIL="<service email>"
    export ANALYTICS_REPORT_IDS="<report id>"
    export ANALYTICS_KEY_PATH="./key.json"
    

There are three main entry points:

  1. deploy-site.ps1
  2. deploy-reports.ps1
  3. deploy-report-schedules.ps1

deploy-site.ps1

Description

This script is run locally on a Windows machine connected to the VPN. The script clones the analytics.ct.gov repository, builds the project with bundler and jekyll, removing development files. It next opens a winscp connection, syncing the local copy of the website to the server, removing outdated files on the server.

Requirements

  1. ruby 2.4.3
  2. bundler

Usage

.\deploy-site.ps1 -UserName "Username" -Password "Password" -HostIP "HostIP" -HostKey "Hostkey"

deploy-reports.ps1

Description

This script is run locally on a Windows machine connected to the VPN. The script creates a WinSCP connection using the Powershell DLL module. With this session, it uploads the .\tasks folder of the analytics.ct.gov-deployment project. It then closes this WinSCP connection.

Requirements

WinSCPnet.dll

Usage

.\deploy-reports.ps1 -UserName "Username" -Password "Password" -HostIP "HostIP" -HostKey "Hostkey" -ProjectLocation "ProjectLocation" -OutputDirectory "OutputDirectory"

Parameters descriptions

ProjectLocation: the location of keys, env scripts, and reports. Should be one of: \analytics-backend OR E:\???\wwwroot\analytics-backend

OutputDirectory: the location of where the scripts place the reports. Should be one of: \analytics\data OR E:\???\wwwroot\analytics\data

deploy-report-schedules.ps1

Description

This script creates an SSH tunnel to start a Powershell instance and run the .\create_tasks.ps1 script on the server.

Requirements

WinSCPnet.dll

Usage

.\deploy-report-schedules.ps1 -UserName "Username" -HostIP "HostIP" -HostKey "Hostkey" -ProjectLocation "ProjectLocation" -OutputDirectory "OutputDirectory"

Parameters descriptions

ProjectLocation: the location of keys, env scripts, and reports. Should be one of: \analytics-backend OR E:\???\wwwroot\analytics-backend

OutputDirectory: the location of where the scripts place the reports. Should be one of: \analytics\data OR E:\???\wwwroot\analytics\data

Other scripts

tasks\create_tasks.ps1

Description

This script is run on the remote machine. It is invoked by the deploy-reports.ps1 script. It starts by running teardown_tasks.ps1 to clean up previously deployed tasks. It then runs npm install to install all the node dependencies for the analytics reports. It next invokes schtasks several times with the different frequencies. The scheduled task runs a powershell instance that immediately invokes the task.ps1 script with supplied parameters.

Usage

Note: This script is not invoked directly by the user.

.\create_tasks.ps1 -ProjectLocation "ProjectLocation" -OutputDirectory "OutputDirectory"

Requirements (on server)

  1. Powershell
  2. Schtasks
  3. Node, npm, npx

task\tasks.ps1

Description

This script is run on the remote machine. It is invoked by the scheduled tasks (created by “create_tasks.ps1”). This script sources the environment variables for the CT context. It then creates the output directory, if it doesn’t already exist. Finally, it runs the analytics reporter via npx.

Usage

Note: This script is not invoked directly by the user.

.\task.ps1 -ProjectLocation "ProjectLocation" -OutputDirectory "OutputDirectory" -Frequency "Frequency"

Requirements (on server)

  1. Node, npm, npx

analytics.ct.gov-deployment's People

Contributors

geramirez avatar cailyncodes avatar chrispmgct avatar

Watchers

James Cloos avatar  avatar

analytics.ct.gov-deployment's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.