Skip to content

mongo install?

mongo install? #20

Workflow file for this run

name: Convert CSV to JSON for Database updates
on:
push:
paths:
- 'db/**'
pull_request:
paths:
- 'db/**'
jobs:
convert:
runs-on: ubuntu-latest
steps:
# Checkout project
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install pandas
run: pip install pandas
- name: Install regex
run: pip install regex
- name: Convert CSV to JSON
run: python db/convert-csv-to-json.py
- name: Upload JSON files as artifacts
uses: actions/upload-artifact@v4
with:
name: json-files
path: db/json/
#remove after testing
mongoimport:
needs: convert
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download JSON files as artifacts
uses: actions/download-artifact@v4
with:
name: json-files
path: db/json/
- name: Install MongoDB Tools
run: |
sudo apt-get update
sudo apt-get install -y wget gnupg
wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
sudo apt-get update
sudo apt-get install -y mongodb-mongosh
- name: Import to MongoDB
run: |
for file in db/json/*.json; do
collection=$(basename "$file" .json)
echo "Importing $file to collection $collection"
mongoimport --type json --uri ${{ secrets.MONGODB_URI }} --collection $collection --file "$file" --drop --maintainInsertionOrder --jsonArray
done
env:
MONGODB_URI: ${{ secrets.MONGODB_URI }}