MapComplete/.forgejo/workflows/update_database.yml

42 lines
1.3 KiB
YAML

on:
schedule:
- cron: "0 0 1 */2 *"
jobs:
daily_data_maintenance:
runs-on: [ lain ]
steps:
- uses: https://source.mapcomplete.org/actions/checkout@v4
- name: Set up Node.js
uses: https://source.mapcomplete.org/actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: package-lock.json
- name: Init all dependencies and layers
shell: bash
run: npm run init
- name: Create export script
shell: bash
run: npm run build:dbscript # output: build_db.lua
- name: Print planet file date
shell: bash
run: |
# LAIN has a weekly updated planet file in /data/planet-latest.osm.pbf
# See https://source.mapcomplete.org/MapComplete/planet-file-updater
TIMESTAMP=$(osmium fileinfo /data/planet-latest.osm.pbf -g header.option.timestamp)
DATE=$(echo $TIMESTAMP | sed "s/T.*//")
echo $DATE
# Create a new database in postgres
vite-node scripts/osm2pgsql/createNewDatabase.ts -- $DATE
echo "Seeding database '$DATE'"
osm2pgsql -O flex -S build_db.lua -s --flat-nodes=import-help-file -d postgresql://user:password@localhost:5444/osm-poi.${DATE} /data/planet-latest.osm.pbf
npm run delete:database:old