Skip to content

Commit

Permalink
Commit files to repo
Browse files Browse the repository at this point in the history
  • Loading branch information
clampr committed Mar 26, 2024
1 parent 6cdca40 commit ca52ee7
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
11 changes: 11 additions & 0 deletions .github/workflows/inventory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ jobs:
python -m pip install mysql-to-sqlite3
- name: Get inventory data
run: mysql2sqlite -f inventory.db -d ${{ secrets.INVENTORY_DB }} -u ${{ secrets.INVENTORY_USER }} --mysql-password ${{ secrets.INVENTORY_PASSWORD }} -h ${{ secrets.INVENTORY_HOST }}
- 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 inventory" --allow-empty)
- name: Push Changes
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
- name: Upload inventory.db
uses: bayssmekanique/action-simple-file-upload@v2
with:
Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/stations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,20 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install pandas
- name: Create stations.db
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/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
- name: Upload stations.db
uses: bayssmekanique/action-simple-file-upload@v2
with:
Expand Down
8 changes: 8 additions & 0 deletions database.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
import json
import sqlite3

import pandas as pd


ROOT_PATH = os.path.dirname(__file__)
STATIONS_PATH = os.path.abspath(os.path.join(ROOT_PATH, "stations"))
QUERY_TABLES_PATH = os.path.abspath(os.path.join(ROOT_PATH, "tables.sql"))
DATABASE_PATH = os.path.abspath(os.path.join(ROOT_PATH, "stations.db"))
LOCATIONS_PATH = os.path.abspath(os.path.join(ROOT_PATH, "locations.csv.gz"))

# Purge DB file
if os.path.exists(DATABASE_PATH):
Expand Down Expand Up @@ -62,6 +65,11 @@
for key, value in data["identifiers"].items()
]


# Extract locations
df = pd.read_sql('SELECT `id`, `latitude`, `longitude`, `elevation` FROM `stations`', conn, index_col='id')
df.to_csv(LOCATIONS_PATH, compression='gzip', header=True)

# Commit changes to database
conn.commit()

Expand Down
Empty file removed requirements.txt
Empty file.

0 comments on commit ca52ee7

Please sign in to comment.