Sync stations #55
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: Sync stations | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 2 * * 0' | |
push: | |
branches: | |
- master | |
paths: | |
- 'stations/*.json' | |
jobs: | |
sync: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install -r requirements.txt | |
- name: Remove stale DB file | |
run: rm -f stations.db | |
- name: Get inventory data | |
run: mysql2sqlite -f stations.db -d ${{ secrets.INVENTORY_DB }} -u ${{ secrets.INVENTORY_USER }} --mysql-password ${{ secrets.INVENTORY_PASSWORD }} -h ${{ secrets.INVENTORY_HOST }} | |
- name: Get station data | |
run: python database.py | |
- name: Commit Files | |
run: | | |
git config --local user.email "${{ vars.GIT_EMAIL }}" | |
git config --local user.name "${{ vars.GIT_USER }}" | |
git add -A | |
git diff-index --quiet HEAD || (git commit -a -m "Sync stations" --allow-empty) | |
- name: Push Changes | |
uses: ad-m/github-push-action@v0.6.0 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ github.ref }} |