name: CD BRouter on: push: branches: [main] paths: - "docker/brouter/**" workflow_dispatch: {} concurrency: group: deploy-brouter cancel-in-progress: true jobs: build: name: Build & Push BRouter Image runs-on: ubuntu-latest permissions: contents: read packages: write steps: - uses: actions/checkout@v6 - uses: docker/login-action@v4 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - uses: docker/build-push-action@v7 with: context: docker/brouter push: true tags: | ghcr.io/trails-cool/brouter:latest ghcr.io/trails-cool/brouter:${{ github.sha }} deploy: name: Deploy BRouter needs: [build] runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - name: Deploy via SSH uses: appleboy/ssh-action@v1 with: host: ${{ secrets.DEPLOY_HOST }} username: root key: ${{ secrets.DEPLOY_SSH_KEY }} script: | cd /opt/trails-cool # Download BRouter segments for Europe (W10-E40, N35-N70) mkdir -p /opt/trails-cool/segments EUROPE_TILES=" W10_N50 W10_N55 W10_N60 W10_N65 W5_N35 W5_N40 W5_N45 W5_N50 W5_N55 W5_N60 W5_N65 E0_N35 E0_N40 E0_N45 E0_N50 E0_N55 E0_N60 E0_N65 E0_N70 E5_N35 E5_N40 E5_N45 E5_N50 E5_N55 E5_N60 E5_N65 E5_N70 E10_N35 E10_N40 E10_N45 E10_N50 E10_N55 E10_N60 E10_N65 E10_N70 E15_N35 E15_N40 E15_N45 E15_N50 E15_N55 E15_N60 E15_N65 E15_N70 E20_N35 E20_N40 E20_N45 E20_N50 E20_N55 E20_N60 E20_N65 E20_N70 E25_N35 E25_N40 E25_N45 E25_N50 E25_N55 E25_N60 E25_N65 E30_N35 E30_N40 E30_N45 E30_N50 E30_N55 E30_N60 E30_N65 E35_N40 E35_N45 E35_N50 E35_N55 E35_N60 E40_N40 E40_N45 E40_N50 E40_N55 " for tile in $EUROPE_TILES; do [ -f "/opt/trails-cool/segments/${tile}.rd5" ] || \ wget -q "https://brouter.de/brouter/segments4/${tile}.rd5" -O "/opt/trails-cool/segments/${tile}.rd5" 2>/dev/null || \ rm -f "/opt/trails-cool/segments/${tile}.rd5" done docker pull ghcr.io/trails-cool/brouter:latest docker compose up -d brouter docker image prune -af # Annotate deploy in Grafana GRAFANA_TOKEN=$(grep GRAFANA_SERVICE_TOKEN .env | cut -d= -f2- 2>/dev/null) if [ -n "$GRAFANA_TOKEN" ]; then docker compose exec -T grafana curl -sf -X POST \ -H "Authorization: Bearer $GRAFANA_TOKEN" \ -H "Content-Type: application/json" \ -d '{"text":"Deploy brouter ${{ github.sha }}","tags":["deploy","brouter"]}' \ http://localhost:3000/api/annotations || true fi