Skip to content

Deploy

Deploy #357

Workflow file for this run

name: Deploy
on:
workflow_dispatch: ~
jobs:
deploy-proxy:
name: Deploy proxy
runs-on: ubuntu-latest
environment: proxy-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
# Manually write import bounds, to decouple proxy from tile generation/import
- name: Output import bounds
run: |
echo '[[-10.0, 35.0], [39.0, 70.0]]' > data/import/bounds.json
- name: Deploy
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
run: |
flyctl deploy --config proxy.fly.toml --local-only
generate-tiles:
name: Generate tiles
runs-on: ubuntu-latest
strategy:
matrix:
# Generate with (Fish shell):
# for i in (seq -10 38); echo "- '$i,35,"(math $i + 1)",70'"; end
bbox:
- '3,50,4,54'
- '4,50,5,54'
- '5,50,6,54'
- '6,50,7,54'
# - '-10,35,-9,70'
# - '-9,35,-8,70'
# - '-8,35,-7,70'
# - '-7,35,-6,70'
# - '-6,35,-5,70'
# - '-5,35,-4,70'
# - '-4,35,-3,70'
# - '-3,35,-2,70'
# - '-2,35,-1,70'
# - '-1,35,0,70'
# - '0,35,1,70'
# - '1,35,2,70'
# - '2,35,3,70'
# - '3,35,4,70'
# - '4,35,5,70'
# - '5,35,6,70'
# - '6,35,7,70'
# - '7,35,8,70'
# - '8,35,9,70'
# - '9,35,10,70'
# - '10,35,11,70'
# - '11,35,12,70'
# - '12,35,13,70'
# - '13,35,14,70'
# - '14,35,15,70'
# - '15,35,16,70'
# - '16,35,17,70'
# - '17,35,18,70'
# - '18,35,19,70'
# - '19,35,20,70'
# - '20,35,21,70'
# - '21,35,22,70'
# - '22,35,23,70'
# - '23,35,24,70'
# - '24,35,25,70'
# - '25,35,26,70'
# - '26,35,27,70'
# - '27,35,28,70'
# - '28,35,29,70'
# - '29,35,30,70'
# - '30,35,31,70'
# - '31,35,32,70'
# - '32,35,33,70'
# - '33,35,34,70'
# - '34,35,35,70'
# - '35,35,36,70'
# - '36,35,37,70'
# - '37,35,38,70'
# - '38,35,39,70'
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 data
run: |
docker pull ghcr.io/hiddewie/openrailwaymap-data:${{ matrix.bbox }}
CONTAINER_ID="$(docker container create ghcr.io/hiddewie/openrailwaymap-data:${{ matrix.bbox }})"
docker cp "$CONTAINER_ID:/data/data.osm.pbf" data/data.osm.pbf
docker container rm "$CONTAINER_ID"
- name: Import data
run: |
docker compose run --build import import
- name: Generate tiles
env:
BBOX: ${{ matrix.bbox }}
run: |
for tile in low-med high standard speed signals electrification; do
docker compose run -e "TILES=$tile" -e BBOX martin-cp
done
- name: List generated tiles
run: |
ls -lah tiles/split/${{ matrix.bbox }}/*.mbtiles
- uses: actions/upload-artifact@v4
with:
name: tiles-${{ matrix.bbox }}
path: |
tiles/*.mbtiles
if-no-files-found: error
retention-days: 3
deploy-tiles:
name: Merge 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: Merge tiles
env:
# for i in (seq -10 38); echo -n "$i,35,"(math $i + 1)",70 "; end
# BBOXES: '-10,35,-9,70 -9,35,-8,70 -8,35,-7,70 -7,35,-6,70 -6,35,-5,70 -5,35,-4,70 -4,35,-3,70 -3,35,-2,70 -2,35,-1,70 -1,35,0,70 0,35,1,70 1,35,2,70 2,35,3,70 3,35,4,70 4,35,5,70 5,35,6,70 6,35,7,70 7,35,8,70 8,35,9,70 9,35,10,70 10,35,11,70 11,35,12,70 12,35,13,70 13,35,14,70 14,35,15,70 15,35,16,70 16,35,17,70 17,35,18,70 18,35,19,70 19,35,20,70 20,35,21,70 21,35,22,70 22,35,23,70 23,35,24,70 24,35,25,70 25,35,26,70 26,35,27,70 27,35,28,70 28,35,29,70 29,35,30,70 30,35,31,70 31,35,32,70 32,35,33,70 33,35,34,70 34,35,35,70 35,35,36,70 36,35,37,70 37,35,38,70 38,35,39,70'
BBOXES: '3,50,4,54 4,50,5,54 5,50,6,54 6,50,7,54'
run: |
docker compose run --entrypoint /tiles/merge.sh -e BBOXES martin-cp
- name: Delete split tiles
run: |
rm -rf tiles/split
- name: List generated tiles
run: |
ls -lah tiles/*.mbtiles
- name: Deploy
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
run: |
flyctl deploy --config martin-static.fly.toml --local-only
deploy-api:
name: Deploy API
runs-on: ubuntu-latest
environment: api-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 }}
- name: Pull database
run: |
docker compose pull db
docker compose up --no-build --pull never --wait db
- name: Prepare and build API container
env:
SKIP_CLEANUP: 'yes'
run: |
api/prepare-api.sh
- name: Print import logs
if: ${{ always() }}
run: |
docker compose logs api-import
- name: Deploy
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
run: |
flyctl deploy --config api.fly.toml --local-only api