Daily Data Export #35
This file contains 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: Daily Data Export | |
on: | |
schedule: | |
- cron: '0 0 * * *' # Runs daily at midnight UTC | |
workflow_dispatch: # Allows manual trigger | |
push: | |
branches: | |
- main # Run on push to main branch | |
jobs: | |
export-data: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # Fetch all history for git operations | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
cache: 'npm' | |
- name: Install dependencies | |
run: npm install mongodb | |
- name: Export data from MongoDB | |
run: node scripts/exportData.js | |
env: | |
REACT_APP_MONGODB_URI: ${{ secrets.REACT_APP_MONGODB_URI }} | |
- name: Configure Git | |
run: | | |
git config user.name "GitHub Action Bot" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
- name: Commit and push if changed | |
run: | | |
git add src/data/ | |
git diff --staged --quiet || (git commit -m "Update data export [skip ci]" && git push) |