Daily Data Update #43
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: Daily Data Update | |
| on: | |
| push: | |
| schedule: | |
| - cron: '0 0 * * *' # Run at midnight UTC daily | |
| workflow_dispatch: # Allows manual triggering for testing | |
| jobs: | |
| update-data: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '18' | |
| - name: Create data logs directory | |
| run: mkdir -p data-logs | |
| - name: Log environment info | |
| run: | | |
| echo "Node version: $(node -v)" > data-logs/environment.txt | |
| echo "Operating system: $(uname -a)" >> data-logs/environment.txt | |
| echo "Date: $(date)" >> data-logs/environment.txt | |
| - name: Run mock data generator | |
| run: node mock-data-generator.js | tee data-logs/generator.log | |
| - name: Verify data file was created | |
| run: | | |
| echo "Listing data directory:" > data-logs/verification.txt | |
| ls -la data/ >> data-logs/verification.txt 2>&1 || echo "No data directory found" >> data-logs/verification.txt | |
| echo "Latest data file content:" >> data-logs/verification.txt | |
| cat data/$(date +%Y-%m-%d).json >> data-logs/verification.txt 2>&1 || echo "No data file found" >> data-logs/verification.txt | |
| continue-on-error: true | |
| - name: Upload logs as artifacts | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: data-generation-logs | |
| path: data-logs/ | |
| - name: Upload data as artifacts | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: generated-data | |
| path: data/ | |
| continue-on-error: true | |
| - name: Commit and push data | |
| run: | | |
| git config --global user.name 'GitHub Actions' | |
| git config --global user.email 'actions@github.com' | |
| git add data/ | |
| git commit -m "Daily data update $(date +%Y-%m-%d)" || echo "No changes to commit" | |
| git push || echo "Push failed, likely no changes" |