This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Convert CSV to JSON for Database updates and release to Azure DB | |
| on: | |
| push: | |
| paths: | |
| - 'db/**' | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| 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/ | |
| mongoimport: | |
| needs: convert | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| mongodb-version: ['6.0'] | |
| 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 Database Tools (Ubuntu 24.04) | |
| run: | | |
| # Add MongoDB 8.0 key to keyring (apt-key is deprecated) | |
| curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc \ | |
| | sudo gpg --dearmor -o /usr/share/keyrings/mongodb-server-8.0.gpg | |
| # Add the Ubuntu 24.04 (noble) repo for mongodb-org 8.0 | |
| echo "deb [arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg] https://repo.mongodb.org/apt/ubuntu noble/mongodb-org/8.0 multiverse" \ | |
| | sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.list | |
| sudo apt-get update | |
| sudo apt-get install -y mongodb-database-tools | |
| - name: Import to MongoDB | |
| run: | | |
| chmod +x ./db/import_json_to_mongo.sh | |
| ./db/import_json_to_mongo.sh | |
| shell: bash | |
| env: | |
| MONGODB_URI: ${{ secrets.MONGODB_URI }} |