Fetch and Merge Crypto Data #155
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: Fetch and Merge Crypto Data | |
on: | |
schedule: | |
- cron: '0 0 * * *' # Runs daily at midnight UTC | |
workflow_dispatch: # Allows manual triggering from the GitHub UI | |
jobs: | |
fetch-and-merge: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Checkout the repository | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
# Step 2: Set up Python 3.x | |
- name: Set up Python 3.x | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
# Step 3: Install Poetry and add to PATH | |
- name: Install Poetry | |
run: | | |
curl -sSL https://install.python-poetry.org | python3 - | |
echo "export PATH=\"$HOME/.local/bin:\$PATH\"" >> $GITHUB_ENV | |
# Step 4: Install project dependencies using Poetry | |
- name: Install dependencies | |
run: | | |
poetry install | |
# Step 5: Set up Kaggle API authentication | |
- name: Setup Kaggle API | |
run: | | |
mkdir $HOME/.kaggle | |
echo '{"username":"${{ secrets.KAGGLE_USERNAME }}","key":"${{ secrets.KAGGLE_KEY }}"}' > $HOME/.kaggle/kaggle.json | |
chmod 600 $HOME/.kaggle/kaggle.json | |
# Step 6: Run the Python script to fetch and process data | |
- name: Run data processing script | |
run: | | |
poetry run python kaggle_bitcoin/kaggle_update_bitcoin.py | |
# Step 7: Upload the updated dataset to Kaggle | |
- name: Upload data to Kaggle | |
run: | | |
utc_date=$(date -u +"%Y-%m-%d") | |
poetry run kaggle datasets version -m "Automated daily update for $utc_date" -p ./upload --dir-mode zip | |