Fetch MongoDB Data #239
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: Fetch MongoDB Data | |
| on: | |
| schedule: | |
| # Run every day at midnight UTC | |
| - cron: "0 0 * * *" | |
| # Allow manual trigger | |
| workflow_dispatch: | |
| # Run on push to main branch | |
| push: | |
| branches: [ main, master ] | |
| jobs: | |
| fetch-data: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Install script dependencies | |
| run: npm install mongodb dotenv | |
| - name: Fetch MongoDB data | |
| run: node scripts/data/fetchMongoData.js | |
| env: | |
| MONGODB_URI: ${{ secrets.MONGODB_URI }} | |
| VITE_MAPBOX_TOKEN: ${{ secrets.VITE_MAPBOX_TOKEN }} | |
| - name: Commit changes | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add -A | |
| git commit -m "Update MongoDB data (automated)" || echo "No changes to commit" | |
| git pull --rebase origin ${{ github.ref_name }} | |
| git push |