This is the main repository for deploying the project. It contains the scripts necessary to deploy analytics.ct.gov to CT’s servers.
- Follow the setup instructions on Analytics-reporter setup instructions
- Create a file called
key.json
inside of thetasks\analytics-reporter\
folder and add the API keys that were collected from Google apis as described in Analytics-reporter setup instructions. - Create a file called
.env
inside of thetasks\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:
- deploy-site.ps1
- deploy-reports.ps1
- deploy-report-schedules.ps1
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.
- ruby 2.4.3
- bundler
.\deploy-site.ps1 -UserName "Username" -Password "Password" -HostIP "HostIP" -HostKey "Hostkey"
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.
WinSCPnet.dll
.\deploy-reports.ps1 -UserName "Username" -Password "Password" -HostIP "HostIP" -HostKey "Hostkey" -ProjectLocation "ProjectLocation" -OutputDirectory "OutputDirectory"
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
This script creates an SSH tunnel to start a Powershell instance and run the .\create_tasks.ps1
script on the server.
WinSCPnet.dll
.\deploy-report-schedules.ps1 -UserName "Username" -HostIP "HostIP" -HostKey "Hostkey" -ProjectLocation "ProjectLocation" -OutputDirectory "OutputDirectory"
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
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.
Note: This script is not invoked directly by the user.
.\create_tasks.ps1 -ProjectLocation "ProjectLocation" -OutputDirectory "OutputDirectory"
- Powershell
- Schtasks
- Node, npm, npx
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.
Note: This script is not invoked directly by the user.
.\task.ps1 -ProjectLocation "ProjectLocation" -OutputDirectory "OutputDirectory" -Frequency "Frequency"
- Node, npm, npx