Skip to content

Publish AIRAC MBTiles #293

Publish AIRAC MBTiles

Publish AIRAC MBTiles #293

Workflow file for this run

name: Publish AIRAC MBTiles
permissions:
contents: write
packages: write
on:
workflow_dispatch:
inputs:
airac_cycle:
description: "AIRAC cycle (e.g. 2503 or 'latest')"
required: false
default: "latest"
bbox:
description: "Bounding box coordinates (min_lon min_lat max_lon max_lat)"
required: true
zoom:
description: "Zoom range (min_zoom max_zoom)"
required: true
default: "12 12"
oaci_prefix:
description: "OACI code prefix for naming (e.g. 'LF' for France)"
required: true
schedule:
- cron: "0 0 * * *" # Daily at midnight UTC
jobs:
check-airac:
runs-on: ubuntu-latest
outputs:
is_airac_start: ${{ steps.check.outputs.is_airac_start }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Check if AIRAC start date
id: check
run: |
IS_START=$(python utils.py is_start)
echo "is_airac_start=$IS_START" >> $GITHUB_OUTPUT
echo "✅ AIRAC start check result: $IS_START"
build-and-release-mbtiles:
runs-on: ubuntu-latest
needs: check-airac
if: ${{ github.event_name != 'schedule' || needs.check-airac.outputs.is_airac_start == '1' }}
steps:
# ────────────────────────────────
# Step 1: Prepare some stuff
# ────────────────────────────────
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt tqdm aiohttp mercantile
# ────────────────────────────────
# Step 2: Determine AIRAC
# ────────────────────────────────
- name: Determine AIRAC
id: airac
run: |
if [ "${{ github.event.inputs.airac_cycle }}" != "" ] && [ "${{ github.event.inputs.airac_cycle }}" != "latest" ]; then
echo "airac=${{ github.event.inputs.airac_cycle }}" >> $GITHUB_OUTPUT
echo "✅ Using manual AIRAC: ${{ github.event.inputs.airac_cycle }}"
else
AIRAC=$(python utils.py airac_current_only)
echo "airac=$AIRAC" >> $GITHUB_OUTPUT
echo "✅ Computed current AIRAC: $AIRAC"
fi
# ────────────────────────────────
# Step 3: Load Regions (auto mode)
# ────────────────────────────────
- name: Load regions from JSON
if: ${{ github.event_name == 'schedule' }}
id: regions
run: |
REGIONS=$(python utils.py regions)
{
echo 'REGIONS<<EOF'
echo "$REGIONS"
echo 'EOF'
} >> $GITHUB_ENV
echo "✅ Loaded regions:"
echo "$REGIONS"
# ────────────────────────────────
# Step 4: Generate MBTiles
# ────────────────────────────────
- name: Generate MBTiles
run: |
set -eo pipefail
mkdir -p mbtiles
if [ "${{ github.event_name }}" == "schedule" ]; then
while read -r REGION; do
# Skip empty lines
[ -z "$REGION" ] && continue
PREFIX=${REGION%%:*}
REST=${REGION#*:}
BBOX_COMMAS=${REST%%:*}
ZOOM_COMMAS=${REST#*:}
BBOX_SPACED=${BBOX_COMMAS//,/ }
ZOOM_SPACED=${ZOOM_COMMAS//,/ }
echo "🔹 Generating for $PREFIX (bbox=$BBOX_SPACED zoom=$ZOOM_SPACED)"
python OFM2MBTiles.py \
--bbox $BBOX_SPACED \
--zoom $ZOOM_SPACED \
--airac ${{ steps.airac.outputs.airac }} \
--oaci-prefix $PREFIX
done <<< "$REGIONS"
else
echo "🔹 Manual run for ${{ github.event.inputs.oaci_prefix }}"
MANUAL_BBOX="${{ github.event.inputs.bbox }}"
MANUAL_ZOOM="${{ github.event.inputs.zoom }}"
python OFM2MBTiles.py \
--bbox $MANUAL_BBOX \
--zoom $MANUAL_ZOOM \
--airac ${{ steps.airac.outputs.airac }} \
--oaci-prefix ${{ github.event.inputs.oaci_prefix }}
fi
# ────────────────────────────────
# Step 5: Collect files
# ────────────────────────────────
- name: Get generated files
id: findfiles
run: |
FILES=$(ls -1 mbtiles/*.mbtiles 2>/dev/null)
if [ -z "$FILES" ]; then
echo "❌ No MBTiles files found!"
exit 1
fi
{
echo 'files<<EOF'
echo "$FILES"
echo 'EOF'
} >> $GITHUB_OUTPUT
echo "📦 Found MBTiles files:"
echo "$FILES"
# ────────────────────────────────
# Step 6: Region names (for release)
# ────────────────────────────────
- name: Compute region names for release
id: region_names
run: |
if [ "${{ github.event_name }}" == "schedule" ]; then
REGION_NAMES=$(python utils.py region_names)
echo "region_names=$REGION_NAMES" >> $GITHUB_OUTPUT
echo "✅ Regions for release: $REGION_NAMES"
else
REGION_NAMES="${{ github.event.inputs.oaci_prefix }}"
echo "region_names=$REGION_NAMES" >> $GITHUB_OUTPUT
echo "✅ Region for release: $REGION_NAMES"
fi
# ────────────────────────────────
# Step 7: Determine run type
# ────────────────────────────────
- name: Automated or Manual run
id: run_type
run: |
if [ "${{ github.event_name }}" == "schedule" ]; then
TYPE="Automated"
else
TYPE="Manual"
fi
echo "run_type=$TYPE" >> $GITHUB_OUTPUT
echo "✅ Run type: $TYPE"
# ────────────────────────────────
# Step 8: Publish release (only main)
# ────────────────────────────────
- name: Create GitHub Release
if: ${{ github.ref == 'refs/heads/main' && env.ACT != 'true' }}
uses: softprops/action-gh-release@v2
with:
tag_name: "AIRAC-${{ steps.airac.outputs.airac }}"
name: "AIRAC ${{ steps.airac.outputs.airac }}"
body: |
**${{ steps.run_type.outputs.run_type }}** release for AIRAC **${{ steps.airac.outputs.airac }}**
Regions: ${{ steps.region_names.outputs.region_names }}
files: ${{ steps.findfiles.outputs.files }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}