Skip to content

Download and push autocomplete.json #33

Download and push autocomplete.json

Download and push autocomplete.json #33

name: Download and push autocomplete.json
on:
schedule:
- cron: "0 0 * * 0"
workflow_dispatch:
permissions:
contents: write
jobs:
download-autocomplete-json:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download autocomplete.json
run: curl -o sozluk/v12/src/v12.autocomplete.json https://sozluk.gov.tr/autocomplete.json
- name: Check if there are any changes
id: verify_diff
run: |
git diff --quiet . || echo "changed=true" >> $GITHUB_OUTPUT
- name: Commit autocomplete.json
if: steps.verify_diff.outputs.changed == 'true'
run: |
sudo apt install --no-install-recommends -y gron
git config diff.gron.textconv "f(){ gron --no-sort \$1 | sed -E 's/\\[[0-9]\\]//g' | sed -E 's/^json\\[\\] = ..;$//g' ; }; f"
git config user.name 'Github Actions'
git config user.email '[email protected]'
echo "Automated download" > commit_msg.txt
echo "" >> commit_msg.txt
git diff --unified=0 sozluk/v12/src/v12.autocomplete.json | sed -E 's/^@.*//g' >> commit_msg.txt
git add sozluk/v12/src/v12.autocomplete.json
git commit -F commit_msg.txt
git push