Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions .github/workflows/ghp-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Build and Deploy Jekyll Site to GitHub Pages

on:
push:
branches: [ master, main ]
pull_request:
branches: [ master, main ]

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Not needed if lastmod is not enabled

# Setup Python
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

# Generate Stan index files
- name: Generate Stan index files
run: python ./ghp-deployment/generate_index_files_for_ghp_deploy.py

# Setup Ruby
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.1' # Not needed with a .ruby-version file
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
cache-version: 0 # Increment this number if you need to re-download cached gems

# Setup Pages
- name: Setup Pages
id: pages
uses: actions/configure-pages@v4

# Build with Jekyll
- name: Build with Jekyll
# Outputs to the './_site' directory by default
run: bundle exec jekyll build --baseurl "example-models"
env:
JEKYLL_ENV: production
PAGES_REPO_NWO: magland/example-models

# Upload artifact
- name: Upload artifact
# Automatically uploads an artifact from the './_site' directory by default
uses: actions/upload-pages-artifact@v3

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
# Deploy only on pushes to master/main branch, not on pull requests
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main')
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
story_cache/
story_files/
.DS_Store
_site
Gemfile.lock
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source "https://rubygems.org"

gem "github-pages", group: :jekyll_plugins
# Ruby ≥3.0 needs this to run `jekyll serve`
gem "webrick", "~> 1.8"
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

This repository holds open source Stan models, data simulators, and real data. There are models translating those found in books, most of the BUGS examples, and some basic examples used in the manual.

**[Open Interactive Browser](https://magland.github.io/example-models)** - View, run, and/or edit these Stan examples directly in your browser using Stan Playground in embedded mode.

#### Books

* [Applied Regression Modeling](https://github.com/stan-dev/example-models/wiki/ARM-Models) (Gelman and Hill 2007)
Expand Down
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
url: https://magland.github.io
31 changes: 31 additions & 0 deletions ghp-deployment/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# GitHub Pages Deployment System

This directory contains tools for the automated deployment of example-models to GitHub Pages with interactive Stan Playground embeds.

## Overview

The `generate_index_files_for_ghp_deploy.py` script automatically generates `index.md` files during the GitHub Actions workflow. It has two main functions:

1. For directories containing `.stan` files:
- Creates index files with Stan Playground embed code
- Includes any corresponding `.data.json` file if present (optional)
- Enables interactive model viewing/editing directly in the browser
- Stan files without `.data.json` still get embedded with empty data

2. For other directories:
- Creates simple index files with links to subdirectories and files
- Maintains navigation structure through the repository

## How it Works

The script is executed automatically by GitHub Actions when changes are pushed to the repository:

1. Recursively processes all directories
2. For each directory:
- Finds all `.stan` files and optional `.data.json` pairs
- Generates appropriate index.md content:
- Stan files get interactive playground embeds (with or without data)
- Other directories get file/folder navigation links
- Creates or updates the index.md file

This automated process enables the interactive browser experience at https://magland.github.io/example-models
Loading