Skip to content

Fetch Coin Data

Fetch Coin Data #81

name: Fetch Coin Data
on:
schedule:
- cron: '0 */12 * * *'
workflow_dispatch: # Allows manual run from the GitHub Actions UI
push:
branches:
- main # Runs on pushes to the main branch
jobs:
fetch_coin_data:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Install dependencies
run: npm install axios
- name: Run Coin Data Fetch Script
run: node coins.cjs
- name: Reset Progress File
if: success()
run: |
echo '{"lastProcessedIndex":-1}' > progress.json
- name: Save JSON to Artifact
if: success()
uses: actions/upload-artifact@v4
with:
name: customCoinData
path: customCoinData.json # The output JSON file
retention-days: 5 # Retain data for a set number of days (optional)
- name: Commit and Push Progress
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name 'genfuture'
git config --global user.email 'g.prem2349@gmail.com'
git add customCoinData.json progress.json
git commit -m "Update Coin Data"
git push https://x-access-token:${GITHUB_TOKEN}@github.com/genfuture/cryptocurrency-scraper.git main