Skip to content

Commit

Permalink
update data
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddewie committed Mar 31, 2024
1 parent dbb5f56 commit 072258b
Showing 1 changed file with 110 additions and 110 deletions.
220 changes: 110 additions & 110 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,69 +60,9 @@ jobs:
# docker compose run import import
# docker compose push import

# update-data:
# name: Update data
# runs-on: ubuntu-latest
#
# steps:
# - name: Checkout
# uses: actions/checkout@v4
#
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
#
# - name: Login to GitHub Container Registry
# uses: docker/login-action@v3
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
#
# # The disk and memory in the Github runners is too small to do large imports.
# # A Docker image with a pre-imported database state is used.
# # During the deployment run, the docker image is updated through the replication updated,
# # comitted to a new image and pushed for future used.
# - name: Pull import database
# run: |
# docker compose pull db
# docker image ls ghcr.io/hiddewie/openrailwaymap-import-db:latest
# docker compose up --no-build --pull never --detach db
#
# - name: Ensure data is up to date
# env:
# # Available cores: 4
# OSM2PGSQL_NUMPROC: 4
# # Available memory: 16GB
# OSM2PGSQL_CACHE: 14000
# run: |
# docker compose pull import
# docker compose build import
# docker compose run import update
# docker compose push import
#
# - name: Commit and push new database image
# run: |
# docker compose stop db
# DB_CONTAINER_ID="$(docker compose ps --all --format json | jq -r 'select(.Service == "db") | .ID')"
# DB_IMAGE="$(docker compose ps --all --format json | jq -r 'select(.Service == "db") | .Image')"
# docker commit "$DB_CONTAINER_ID" "$DB_IMAGE"
# docker image ls "$DB_IMAGE"
# docker push "$DB_IMAGE"

generate-tiles:
name: Generate tiles
update-data:
name: Update data
runs-on: ubuntu-latest
# needs: update-data

strategy:
matrix:
tiles:
- low-med
- standard
- speed
- signals
- electrification
- gauge

steps:
- name: Checkout
Expand All @@ -138,61 +78,121 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# The disk and memory in the Github runners is too small to do large imports.
# A Docker image with a pre-imported database state is used.
# During the deployment run, the docker image is updated through the replication updated,
# comitted to a new image and pushed for future used.
- name: Pull import database
run: |
docker compose pull db
docker image ls ghcr.io/hiddewie/openrailwaymap-import-db:latest
docker compose up --no-build --pull never --detach db
- name: Generate tiles
- name: Ensure data is up to date
env:
TILES: ${{ matrix.tiles }}
# Available cores: 4
OSM2PGSQL_NUMPROC: 4
# Available memory: 16GB
OSM2PGSQL_CACHE: 14000
run: |
docker compose run martin-cp
ls -las tiles/
- uses: actions/upload-artifact@v4
with:
name: tiles-${{ matrix.tiles }}
path: |
tiles/*.mbtiles
if-no-files-found: error
retention-days: 3

deploy-tiles:
name: Deploy tiles
runs-on: ubuntu-latest
needs: generate-tiles
environment: tiles-production

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Setup Fly
uses: superfly/flyctl-actions/setup-flyctl@master

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/download-artifact@v4
with:
# No name: download everything
path: tiles
merge-multiple: true
docker compose pull import
docker compose build import
docker compose run import update
docker compose push import
- name: List generated tiles
- name: Commit and push new database image
run: |
ls -lah tiles/
docker compose stop db
DB_CONTAINER_ID="$(docker compose ps --all --format json | jq -r 'select(.Service == "db") | .ID')"
DB_IMAGE="$(docker compose ps --all --format json | jq -r 'select(.Service == "db") | .Image')"
docker commit "$DB_CONTAINER_ID" "$DB_IMAGE"
docker image ls "$DB_IMAGE"
# docker push "$DB_IMAGE"

- name: Deploy
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
run: |
flyctl deploy --config martin-static.fly.toml --local-only
# generate-tiles:
# name: Generate tiles
# runs-on: ubuntu-latest
## needs: update-data
#
# strategy:
# matrix:
# tiles:
# - low-med
# - standard
# - speed
# - signals
# - electrification
# - gauge
#
# steps:
# - name: Checkout
# uses: actions/checkout@v4
#
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
#
# - name: Login to GitHub Container Registry
# uses: docker/login-action@v3
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
#
# - name: Pull import database
# run: |
# docker compose pull db
# docker compose up --no-build --pull never --detach db
#
# - name: Generate tiles
# env:
# TILES: ${{ matrix.tiles }}
# run: |
# docker compose run martin-cp
# ls -las tiles/
#
# - uses: actions/upload-artifact@v4
# with:
# name: tiles-${{ matrix.tiles }}
# path: |
# tiles/*.mbtiles
# if-no-files-found: error
# retention-days: 3
#
# deploy-tiles:
# name: Deploy tiles
# runs-on: ubuntu-latest
# needs: generate-tiles
# environment: tiles-production
#
# steps:
# - name: Checkout
# uses: actions/checkout@v4
#
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
#
# - name: Setup Fly
# uses: superfly/flyctl-actions/setup-flyctl@master
#
# - name: Login to GitHub Container Registry
# uses: docker/login-action@v3
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
#
# - uses: actions/download-artifact@v4
# with:
# # No name: download everything
# path: tiles
# merge-multiple: true
#
# - name: List generated tiles
# run: |
# ls -lah tiles/
#
# - name: Deploy
# env:
# FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
# run: |
# flyctl deploy --config martin-static.fly.toml --local-only

0 comments on commit 072258b

Please sign in to comment.