Publish SQLite and CSV dataset with GitHub Actions

This commit is contained in:
Nemo 2024-07-02 14:53:39 +05:30
parent 5f8263844c
commit 6839f54d75

32
.github/workflows/publish.yml vendored Normal file
View File

@ -0,0 +1,32 @@
name: Publish Dataset
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # Runs at midnight UTC every day
jobs:
publish:
needs: update
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install csv-to-sqlite
run: pip install csv-to-sqlite
- name: Convert JSON to CSV
run: jq -r '"kb,date,url,slug,uuid", keys[] as $k | [$k] + [ .[$k].date, .[$k].url, .[$k].slug, .[$k].uuid ]|@csv' data.json > data.csv
- name: Convert CSV to SQLite
run: csv-to-sqlite -f data.csv -o data.sqlite --tables data --columns "date,uuid,url,slug,kb"
- name: Create and push tag
run: |
TAG_NAME=v$(date +'%Y.%m.%d')
git tag $TAG_NAME
git push origin $TAG_NAME
- name: Publish files to GitHub Releases
run: |
gh release create $TAG_NAME data.json data.csv data.sqlite --title "Release $TAG_NAME"