Skip to content

update-article-count #218

update-article-count

update-article-count #218

Workflow file for this run

name: update-article-count
on:
push:
branches: ["main"]
schedule:
- cron: 0 0 * * *
workflow_dispatch:
jobs:
fetch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up directory and environment
run: |
git config user.name 'Actions'
git config user.email '[email protected]'
echo "$GITHUB_WORKSPACE" && cd "$GITHUB_WORKSPACE"
- name: Fetch data from YTWiki's API
run: |
int=$(curl 'https://youtube.fandom.com/api.php?action=query&format=json&meta=siteinfo&formatversion=latest&siprop=statistics' | jq --raw-output '.query.statistics.articles')
echo "{\"int\":$int}" > count.json
- name: Commit change
run: |
git add count.json
git commit -m "Fetched today's article count" || echo 'Source is the same as repository. Skipping push...'
git push -u origin main
echo 'Job done!'