clone

an offline map explorer where each world, from a game map to a city's open data, ships as one .atlas file

feat/atlas-next-horizon
atlas / .github / workflows / snapshot.yml
snapshot.yml 5.6K
1# Snapshot builds one city's .atlas on a schedule and publishes it only when2# the city changed. It is reusable: a caller names the city and provides the3# state -- a capture archive committed to a branch of the calling repository --4# and this workflow crawls, composes, enriches, gates on the bundle's own5# content stamp, and publishes to the caller's releases. A city IT team runs6# their own copy in a private repository with their curation and their key;7# this repository's scheduler runs it over the public proof cities as the8# living test of the same path.9#10# PARKED (issue #5 §7, M7). The pipeline steps below are the clean room's --11# `atlas crawl|tiles|compose|enrich` in place of the archived tools/ programs12# -- but the ArcGIS/USGS crawler is the one crawler the rewrite has not built:13# `atlas crawl -source list` offers `ign` and nothing else, and docs/generate.md14# §3.2 says why (the city's archive was an input to the rewrite rather than15# something the lane could take). A run therefore fails at the crawl step, and16# the scheduler in snapshots.yml is dispatch-only until it does not.17#18# What unblocks it is one crawler under internal/generate/crawl, registered as19# `arcgis-hub`, fetching a curated city's hub layers and the two USGS national20# services by bounding box. Everything after it here is already the shipped21# path; the composition and enrichment of that archive are proven by the22# `bend-or` bundle fixture, which reproduces byte-identically (docs/generate.md23# §8).24name: Snapshot2526on:27 workflow_call:28 inputs:29 city:30 description: "curated city slug, e.g. bend-or"31 required: true32 type: string33 atlas-ref:34 description: "atlas ref to build with"35 required: false36 type: string37 default: main38 state-branch:39 description: "branch of the calling repository holding the fmg-archive"40 required: false41 type: string42 default: snapshots4344permissions:45 contents: write4647env:48 CGO_ENABLED: "0"49 GOFLAGS: -trimpath -buildvcs=false5051jobs:52 snapshot:53 runs-on: ubuntu-24.0454 steps:55 - name: Check out snapshot state56 uses: actions/checkout@v457 with:58 ref: ${{ inputs.state-branch }}59 path: state60 # The state branch must exist; docs/snapshots.md shows the one-time61 # orphan-branch setup.6263 - name: Check out atlas64 uses: actions/checkout@v465 with:66 repository: FelineStateMachine/atlas67 ref: ${{ inputs.atlas-ref }}68 path: atlas6970 # A city that should stay out of a public repository is carried by the71 # `atlas-ref` input: point it at a branch or fork whose curation table72 # names the city. The reference tree's habit of dropping a gitignored73 # companion file into the source package is not carried over -- the74 # clean room's table is a gate, and a gate that can be extended by a file75 # nobody reviews is not one (internal/generate/sources/arcgishub).7677 - uses: actions/setup-go@v578 with:79 go-version-file: atlas/go.mod80 cache-dependency-path: atlas/go.sum8182 - name: Crawl83 working-directory: atlas84 run: |85 go run ./cmd/atlas crawl -archive ../state/fmg-archive \86 -source arcgis-hub "${{ inputs.city }}"8788 - name: Compose and enrich89 working-directory: atlas90 run: |91 go run ./cmd/atlas tiles -archive ../state/fmg-archive -output build/tiles92 go run ./cmd/atlas compose -archive ../state/fmg-archive \93 -tiles build/tiles/index.json -bundles ../out94 go run ./cmd/atlas enrich -archive ../state/fmg-archive \95 -tiles build/tiles/index.json -bundles ../out9697 - name: Gate on the stamp98 id: gate99 working-directory: out100 env:101 GH_TOKEN: ${{ github.token }}102 run: |103 FILE=$(ls ${{ inputs.city }}-*.atlas | sort | tail -1)104 echo "file=$FILE" >> "$GITHUB_OUTPUT"105 if gh release view "snapshot-${{ inputs.city }}" --repo "$GITHUB_REPOSITORY" \106 --json assets -q '.assets[].name' 2>/dev/null | grep -qx "$FILE"; then107 echo "unchanged: $FILE is already published"108 echo "changed=false" >> "$GITHUB_OUTPUT"109 else110 echo "changed=true" >> "$GITHUB_OUTPUT"111 fi112113 - name: Commit the archive114 if: steps.gate.outputs.changed == 'true'115 working-directory: state116 run: |117 git config user.name "atlas-snapshot"118 git config user.email "snapshot@users.noreply.github.com"119 git add -A120 git diff --cached --quiet || git commit -m "snapshot ${{ inputs.city }}: ${{ steps.gate.outputs.file }}"121 git push122123 - name: Publish124 if: steps.gate.outputs.changed == 'true'125 env:126 GH_TOKEN: ${{ github.token }}127 run: |128 FILE="${{ steps.gate.outputs.file }}"129 RELEASE="snapshot-${{ inputs.city }}"130 if ! gh release view "$RELEASE" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then131 gh release create "$RELEASE" --repo "$GITHUB_REPOSITORY" \132 --title "Snapshots: ${{ inputs.city }}" \133 --notes "Scheduled .atlas snapshots. Every published version stays; *-latest.atlas always names the newest." \134 --target "${{ inputs.state-branch }}"135 fi136 cp "out/$FILE" "out/${{ inputs.city }}-latest.atlas"137 gh release upload "$RELEASE" --repo "$GITHUB_REPOSITORY" \138 "out/$FILE" "out/${{ inputs.city }}-latest.atlas#${{ inputs.city }}-latest.atlas" --clobber139 echo "published $FILE"