Skip to content

Update File with API Data #27323

Update File with API Data

Update File with API Data #27323

Workflow file for this run

name: Update File with API Data
on:
schedule:
- cron: '*/5 * * * *' # Runs every 5 minutess
push:
branches:
- main
jobs:
update-file:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Fetch Data from API
run: |
API_DATA=$(curl -s "https://www.udemy.com/api-2.0/courses/4460762/?fields%5Bcourse%5D=num_subscribers")
echo "API Data: $API_DATA"
CSV_DATA=$(echo "$API_DATA" | jq -r '[{"subscribers": .num_subscribers}] | (.[0] | keys_unsorted) as $keys | $keys, map([.[ $keys[] ]])[] | @csv')
echo "CSV Data: $CSV_DATA"
echo "$CSV_DATA" > api_data.csv
- name: Commit and Push Changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "Update data from API"
commit_user_name: "GitHub Actions"
commit_user_email: "actions@github.com"