Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IT-3230] Move agora data manager CI #116

Merged
merged 13 commits into from
Jan 5, 2024
10 changes: 2 additions & 8 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,14 @@ on:

jobs:
deploy:
# self hosted runners are setup in github to match branch names
# self hosted runner labels are setup in github to match branch names
runs-on: [self-hosted, ${{ github.ref_name }}]
# context environment variables are setup in github to match branch names
# variables in context environments are setup in github to match branch names
environment:
name: ${{ github.ref_name }}

steps:
- uses: actions/checkout@v4
- uses: BSFishy/pip-action@v1
with:
packages: |
synapseclient[pandas,pysftp]
- name: Setup mongo tools - mongo-tools and mongo-shell
uses: boly38/action-mongo-tools@stable
- name: Import Synapse Data
run: ./import-data.sh $BRANCH $SYNAPSE_USERNAME $SYNAPSE_PASSWORD $DB_HOST $DB_USER $DB_PASS
env:
Expand Down
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Overview
Agora Data Manager is a tool that loads the JSON files into Agora's document database instances in our AWS environments.
Agora Data Manager is a tool that loads the JSON files into Agora's document database
instances in our AWS environments.

# Purpose
This project allows Agora maintainers to update the Agora database with
Expand Down Expand Up @@ -55,17 +56,19 @@ Context specific secrets for each environment that corresponds to a git branch (

## Self hosted runners

We setup a bastian host in AWS for each environment which have access to the
databases. Then we associate those bastian hosts to
[Github self-hosted runners](https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/about-self-hosted-runners#about-self-hosted-runners).
The update is executed from these runners. Each runner corresponds
to an environment which corresponds to a git branch. When a push happens on a
branch (i.e. develop), the update is executed on the `agora-bastian-develop` runner
which in turn updates the development database.
[agora2-infra] repository deploys a bastian host in AWS for each environment which have access to
zaro0508 marked this conversation as resolved.
Show resolved Hide resolved
the databases. We manually configure a [Github self-hosted runner] for each bastian host,
a label is applied to each runner to match the corresponding deployment branch name (develop/staging/prod).
Each runner corresponds to an environment which corresponds to a git branch. The update is
executed from these runners. When a push happens on a branch (i.e. develop), the update
is executed on the `agora-bastian-develop` runner which in turn updates the development database.


![alt text][self_hosted_runners]


[db_update]: agora-db-update.drawio.png "update diagram"
[github_secrets]: github_secrets.png "github secrets screen"
[self_hosted_runners]: self-hosted-runners.png "self hosted runners"
[agora2-infra]: https://github.com/Sage-Bionetworks/agora2-infra "agora2-infra repository"
[Github self-hosted runners]: https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/about-self-hosted-runners#about-self-hosted-runners
Binary file modified agora-db-update.drawio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions import-data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ DB_USER=$5
DB_PASS=$6

CURRENT_DIR=$(pwd)
PARENT_DIR="$(dirname "$CURRENT_DIR")"
TMP_DIR=/tmp
WORKING_DIR=$TMP_DIR/work
WORKING_DIR=$CURRENT_DIR
DATA_DIR=$WORKING_DIR/data
TEAM_IMAGES_DIR=$DATA_DIR/team_images

mkdir -p $TEAM_IMAGES_DIR

# Version key/value should be on his own line
DATA_VERSION=$(cat $WORKING_DIR/data-manifest.json | grep data-version | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g' | tr -d '[[:space:]]')
DATA_MANIFEST_ID=$(cat $WORKING_DIR/data-manifest.json | grep data-manifest-id | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g' | tr -d '[[:space:]]')
Expand Down