Skip to content

Analyze

Analyze #80

Workflow file for this run

name: Analyze
on:
workflow_dispatch:
inputs:
refresh_cache:
description: Refresh OpenSkiMap download
type: boolean
required: true
default: false
solar_segment_count:
description: Number of uncached run segments to compute solar irradiation for
type: number
required: false
default: 5000
schedule:
- cron: "0 10 * * SAT" # https://crontab.guru/#0_10_*_*_SAT
jobs:
analyze:
runs-on: ubuntu-latest
permissions:
contents: write
# default timeout of 360 minutes is the max supported by GitHub-hosted runners,
# which is too short to compute all solar irradiation values
timeout-minutes: 360
steps:
- uses: actions/checkout@v4
- uses: ./.github/workflows/setup-python
- uses: ./.github/workflows/setup-r
- uses: ./.github/workflows/setup-quarto
- name: install fonts
run: sudo apt-get install --yes --quiet fonts-dejavu-core fonts-noto-cjk
# GitHub will remove any cache entries that have not been accessed in over 7 days
- name: Cache OpenSkiMap
id: cache-openskimap
uses: actions/cache@v4
with:
path: data/openskimap
key: openskimap
lookup-only: ${{ toJSON(inputs.refresh_cache) }}
- name: Debug Inputs
run: |
echo "refresh_cache: ${{ inputs.refresh_cache }}"
echo "refresh_cache json: ${{ toJSON(inputs.refresh_cache) }}"
echo "cache miss: ${{ steps.cache-openskimap.outputs.cache-hit != 'true' }}"
echo "cache-hit: ${{ steps.cache-openskimap.outputs.cache-hit }}"
echo "cache-hit json: ${{ toJSON(steps.cache-openskimap.outputs.cache-hit) }}"
echo "solar_segment_count: ${{ inputs.solar_segment_count }}"
echo "solar_segment_count json: ${{ toJSON(inputs.solar_segment_count) }}"
echo "OPENSKISTATS_SOLAR_SEGMENT_COUNT: ${{ inputs.solar_segment_count || 300000 }}"
echo "OPENSKISTATS_SOLAR_SEGMENT_COUNT json: ${{ toJSON(inputs.solar_segment_count || 300000) }}"
- name: Download OpenSkiMap
# confusing behavior where inputs.refresh_cache acts like a string not a boolean
# https://stackoverflow.com/questions/76292948/github-action-boolean-input-with-default-value
# https://github.com/actions/runner/issues/1483
if: toJSON(inputs.refresh_cache) || steps.cache-openskimap.outputs.cache-hit != 'true'
# the step if condition stopped working around 2025-01-03, so use bash condition to skip the download if files exist
run: |
if [ ! -f "data/openskimap/runs.geojson.xz" ]; then
uv run openskistats download
fi
shell: bash
- name: Python Analysis
env:
OPENSKISTATS_SOLAR_SEGMENT_COUNT: ${{ inputs.solar_segment_count || 300000 }}
run: |
uv run openskistats analyze
uv run openskistats validate
uv run openskistats visualize
shell: bash
- name: Make story plots
working-directory: r/
run: |
Rscript 01.data.R
Rscript 02.plot.R
- name: Quarto Render
run: uv run quarto render website
- name: Publish data
uses: peaceiris/actions-gh-pages@v4
if: github.ref == 'refs/heads/main'
with:
publish_branch: data
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./data
# it's not clear how exclude_assets works
# https://github.com/peaceiris/actions-gh-pages/blob/ababa3d330af34b07419f6bc9f4a6b817ed7930b/src/git-utils.ts#L21-L39
exclude_assets: "data/website,data/openskistats"
force_orphan: true
# remove the unnecessary .nojekyll file
enable_jekyll: true
- name: Deploy website
uses: peaceiris/actions-gh-pages@v4
if: github.ref == 'refs/heads/main'
with:
publish_branch: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./data/webapp
exclude_assets: "**.xz,**.parquet"
force_orphan: true
cname: openskistats.org