Database builder #585
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Database builder" | |
on: | |
schedule: | |
- cron: "0 0 * * *" | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@master | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.8" | |
- name: Install dependencies | |
run: | | |
sudo apt install gzip -y | |
python -m pip install -r .github/scripts/requirements.txt | |
- name: Check if update available | |
id: update | |
run: | | |
LOCAL="$(cat VERSION)" | |
REMOTE="$(python .github/scripts/builder.py get-latest)" | |
[[ "${LOCAL}" != "${REMOTE}" ]] && STATUS="true" || STATUS="false" | |
[[ "${{ github.event_name }}" == "workflow_dispatch" ]] && STATUS="true" | |
echo "::set-output name=available::$STATUS" | |
echo "${REMOTE}" > VERSION | |
- name: Building & update database... | |
if: steps.update.outputs.available == 'true' | |
id: build | |
run: | | |
OUT="db.json" | |
python .github/scripts/builder.py 1>$OUT | |
gzip -cf $OUT > $OUT.gz | |
echo "::set-output name=changes::$(git status -s | wc -l)" | |
- name: Commit changes | |
if: steps.build.outputs.changes > 0 | |
run: | | |
git config --local user.email "dwisiswant0@users.noreply.github.com" | |
git config --local user.name "Dwi Siswanto" | |
git add . | |
git commit -m "Update DB [$(date)] :robot:" | |
git push origin master |