Skip to content

Merge pull request #792 from OpenHistoricalMap/overpass-turbo-v2.1.15 #4

Merge pull request #792 from OpenHistoricalMap/overpass-turbo-v2.1.15

Merge pull request #792 from OpenHistoricalMap/overpass-turbo-v2.1.15 #4

name: Build and Publish OHM Stats Dashboard
on:
push:
branches:
- "main"
- "staging"
workflow_dispatch:
env:
DASHBOARD_REPO: danvk/ohm
DASHBOARD_GITSHA: 58c9bca6894a76158242b2025bfcba29ada6ddd8
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
jobs:
build:
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.13.0
with:
access_token: ${{ github.token }}
- name: Set environment variables - Staging
if: github.ref == 'refs/heads/staging'
uses: allenevans/set-env@v4.0.0
with:
CLOUDFLARE_PROJECT: ohm-planet-stats-dash-staging
DASHBOARD_SERVER: https://s3.amazonaws.com/planet-staging.openhistoricalmap.org/planet-stats
- name: Set environment variables - Production
if: github.ref == 'refs/heads/main'
uses: allenevans/set-env@v4.0.0
with:
CLOUDFLARE_PROJECT: ohm-planet-stats-dash-production
DASHBOARD_SERVER: https://s3.amazonaws.com/planet.openhistoricalmap.org/planet-stats
- name: Checkout dashboard repo
uses: actions/checkout@v6
with:
repository: ${{ env.DASHBOARD_REPO }}
ref: ${{ env.DASHBOARD_GITSHA }}
path: ohm
- name: Prepare publish dir
run: |
mkdir -p site/dashboard
cp ohm/index.html site/
cp -r ohm/dashboard/. site/dashboard/
sed -i "s|export const SERVER = .*;|export const SERVER = \"${DASHBOARD_SERVER}\";|" site/dashboard/metrics.js
echo "SERVER set to:"; grep "export const SERVER" site/dashboard/metrics.js
ls -la site site/dashboard
- name: Deploy to Cloudflare Pages
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.DEPLOY_CLOUDFLARE_PAGES_API_TOKEN }}
accountId: ${{ env.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy site --project-name=${{ env.CLOUDFLARE_PROJECT }} --branch=${{ github.ref_name }}