From 2737e026b3f4975bc2f92665d908a8dfc4156d89 Mon Sep 17 00:00:00 2001 From: Qiusheng Wu Date: Tue, 2 Jul 2024 23:24:52 -0400 Subject: [PATCH] Add python script --- .github/dependabot.yml | 19 +++++++++++ .github/workflows/deploy.yml | 2 +- .github/workflows/update_maplibre.yml | 47 +++++++++++++++++++++++++++ .gitignore | 1 + maplibre/chlor_a.html | 34 ------------------- maplibre/google_buildings.html | 34 ------------------- maplibre/guam.html | 34 ------------------- maplibre/nyc.html | 34 ------------------- maplibre/st_helen.html | 34 ------------------- maplibre/vancouver.html | 34 ------------------- maplibre/video.html | 34 ------------------- requirements.txt | 1 + update_maplibre.py | 15 +++++++++ 13 files changed, 84 insertions(+), 239 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/update_maplibre.yml delete mode 100644 maplibre/chlor_a.html delete mode 100644 maplibre/google_buildings.html delete mode 100644 maplibre/guam.html delete mode 100644 maplibre/nyc.html delete mode 100644 maplibre/st_helen.html delete mode 100644 maplibre/vancouver.html delete mode 100644 maplibre/video.html create mode 100644 requirements.txt create mode 100644 update_maplibre.py diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..0372e10 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,19 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + +version: 2 +updates: + - package-ecosystem: "docker" + directory: "/" + schedule: + interval: "weekly" + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "weekly" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 0a12ba3..573c0e2 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - python-version: [3.9] + python-version: ["3.11"] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/update_maplibre.yml b/.github/workflows/update_maplibre.yml new file mode 100644 index 0000000..38d5032 --- /dev/null +++ b/.github/workflows/update_maplibre.yml @@ -0,0 +1,47 @@ +name: update_maplibre +on: + workflow_dispatch: + schedule: + - cron: "0 22 * * *" # https://crontab.guru/ + +jobs: + build: + runs-on: ubuntu-latest + + env: + MAPTILER_KEY: ${{ secrets.MAPTILER_KEY }} + MAPTILER_KEY_PUBLIC: ${{ secrets.MAPTILER_KEY_PUBLIC }} + + steps: + - name: checkout repo content + uses: actions/checkout@v3 + + - name: setup python + uses: actions/setup-python@v4 + with: + python-version: "3.11" + + - name: install python packages + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + - name: execute python script + run: | + python update_maplibre.py + - name: file_check + run: ls -l -a + - name: commit files + continue-on-error: true + run: | + today=$(date +"%Y-%m-%d") + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git add -A + git commit -m "Updated MapLibre maps ${today} UTC" -a + git pull origin main + - name: push changes + continue-on-error: true + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: main diff --git a/.gitignore b/.gitignore index b6e4761..485bb2f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ __pycache__/ *.so # Distribution / packaging +*.zip .Python build/ develop-eggs/ diff --git a/maplibre/chlor_a.html b/maplibre/chlor_a.html deleted file mode 100644 index 533104f..0000000 --- a/maplibre/chlor_a.html +++ /dev/null @@ -1,34 +0,0 @@ - - - -Chlorophyll-a - - - - - -
- - - \ No newline at end of file diff --git a/maplibre/google_buildings.html b/maplibre/google_buildings.html deleted file mode 100644 index 635238e..0000000 --- a/maplibre/google_buildings.html +++ /dev/null @@ -1,34 +0,0 @@ - - - -Leafmap - - - - - -
- - - \ No newline at end of file diff --git a/maplibre/guam.html b/maplibre/guam.html deleted file mode 100644 index 305ee6f..0000000 --- a/maplibre/guam.html +++ /dev/null @@ -1,34 +0,0 @@ - - - -Guam - - - - - -
- - - \ No newline at end of file diff --git a/maplibre/nyc.html b/maplibre/nyc.html deleted file mode 100644 index 7ba7be7..0000000 --- a/maplibre/nyc.html +++ /dev/null @@ -1,34 +0,0 @@ - - - -Leafmap - - - - - -
- - - \ No newline at end of file diff --git a/maplibre/st_helen.html b/maplibre/st_helen.html deleted file mode 100644 index 09792e1..0000000 --- a/maplibre/st_helen.html +++ /dev/null @@ -1,34 +0,0 @@ - - - -Leafmap - - - - - -
- - - \ No newline at end of file diff --git a/maplibre/vancouver.html b/maplibre/vancouver.html deleted file mode 100644 index 7f6fa6c..0000000 --- a/maplibre/vancouver.html +++ /dev/null @@ -1,34 +0,0 @@ - - - -Leafmap - - - - - -
- - - \ No newline at end of file diff --git a/maplibre/video.html b/maplibre/video.html deleted file mode 100644 index 7a1b8e3..0000000 --- a/maplibre/video.html +++ /dev/null @@ -1,34 +0,0 @@ - - - -Video on a map - - - - - -
- - - \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..60920f2 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +leafmap["maplibre"] \ No newline at end of file diff --git a/update_maplibre.py b/update_maplibre.py new file mode 100644 index 0000000..6546da6 --- /dev/null +++ b/update_maplibre.py @@ -0,0 +1,15 @@ +import os +import shutil +import leafmap.maplibregl as leafmap + +url = "https://github.com/giswqs/leafmap/archive/refs/heads/master.zip" +out_zip = "leafmap-master.zip" +leafmap.download_file(url, out_zip) + +in_dir = "leafmap-master/docs/maplibre" +out_dir = "maplibre" + +leafmap.execute_maplibre_notebook_dir(in_dir, out_dir, replace_api_key=True) + +shutil.rmtree("leafmap-master") +os.remove("leafmap-master.zip")