Skip to content

Hourly Data Fetch #11393

Hourly Data Fetch

Hourly Data Fetch #11393

Workflow file for this run

name: Hourly Data Fetch
on:
push:
branches: [ main ]
schedule:
- cron: '*/5 * * * *' # Runs every hour
jobs:
fetch_data:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Node.js environment
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Fetch akiprices.json
run: |
echo "Fetching akiprices.json..."
curl -o akiprices.json https://dev.sp-tarkov.com/SPT-AKI/Server/raw/branch/master/project/assets/database/templates/prices.json
- name: Run fetch request and process data
run: |
echo "Running fetch request..."
DATA=$(curl -X POST https://api.tarkov.dev/graphql \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"query": "{ items(type: any){ id avg24hPrice } }"
}')
echo "Processing data..."
PROCESSED_DATA=$(echo $DATA | node -e "\
const fs = require('fs');
const data = JSON.parse(fs.readFileSync(0, 'utf-8'));
const akiPrices = JSON.parse(fs.readFileSync('akiprices.json', 'utf-8'));
const processedData = {};
data.data.items.forEach(item => {
if (akiPrices[item.id]) {
processedData[item.id] = item.avg24hPrice;
}
});
console.log(JSON.stringify(processedData));
")
echo $PROCESSED_DATA > prices.json
- name: Commit and push changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add prices.json
git commit -m "Update prices.json"
git push