Skip to content

Daily Stock Price History Backup #19

Daily Stock Price History Backup

Daily Stock Price History Backup #19

Workflow file for this run

name: Daily Stock Price History Backup
on:
schedule:
- cron: '0 0 * * *' # Every day at 00:00 UTC
workflow_dispatch:
permissions:
contents: write # Required to allow pushing changes to the repo
jobs:
backup:
runs-on: ubuntu-latest
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
steps:
- name: Checkout backups branch
uses: actions/checkout@v3
with:
ref: backups
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10.13'
architecture: 'x64'
- name: Install dependencies
run: pip install asyncpg pandas
- name: Run export script
run: python .github/scripts/export_stock_history.py
- name: Commit and push CSV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "github-actions"
git config user.email "actions@github.com"
git add stock_price_history.csv
git commit -m "📊 Daily backup: $(date -u +'%Y-%m-%d')" || echo "No changes to commit"
git push https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }} HEAD:backups --force