Merge pull request #13 from cmu-soda/add-fmm-project #37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy Jekyll site to Pages | |
| on: | |
| push: | |
| branches: ["master"] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| env: | |
| RUBY_VERSION_FULL: "3.1.4" # exact version | |
| RUBY_VERSION_SHORT: "3.1" # what setup-ruby will request | |
| jobs: | |
| build: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Ensure Ruby in toolcache (self-hosted safe) | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| TOOLCACHE_DIR="${RUNNER_TOOL_CACHE:-/opt/hostedtoolcache}" | |
| RUBY_DIR="$TOOLCACHE_DIR/Ruby/$RUBY_VERSION_FULL/x64" | |
| SENTINEL="$RUBY_DIR.complete" | |
| LOCK="/var/tmp/ruby-${RUBY_VERSION_FULL}.lock" | |
| echo "Toolcache dir: $TOOLCACHE_DIR" | |
| echo "Target Ruby dir: $RUBY_DIR" | |
| if [ -f "$SENTINEL" ]; then | |
| echo "Ruby $RUBY_VERSION_FULL already present (sentinel found)." | |
| exit 0 | |
| fi | |
| if command -v ruby >/dev/null 2>&1; then | |
| INSTALLED="$(ruby -e 'print RUBY_VERSION' || true)" | |
| if [[ "${INSTALLED:-}" == ${RUBY_VERSION_SHORT}.* ]]; then | |
| echo "A matching Ruby ${INSTALLED} is already available on PATH; skipping toolcache build." | |
| exit 0 | |
| fi | |
| fi | |
| sudo mkdir -p "$RUBY_DIR" | |
| sudo chown -R "$USER":"$USER" "$TOOLCACHE_DIR" | |
| exec 9>"$LOCK" | |
| if ! flock -n 9; then | |
| echo "Another job is building Ruby. Waiting on lock..." | |
| flock 9 | |
| fi | |
| if [ -f "$SENTINEL" ]; then | |
| echo "Ruby $RUBY_VERSION_FULL now present (sentinel found after lock)." | |
| exit 0 | |
| fi | |
| echo "Installing build prerequisites..." | |
| sudo apt-get update -y | |
| sudo apt-get install -y \ | |
| build-essential autoconf bison \ | |
| libssl-dev zlib1g-dev libreadline-dev libyaml-dev \ | |
| libxml2-dev libxslt1-dev libffi-dev libgdbm-dev \ | |
| libdb-dev uuid-dev | |
| echo "Installing ruby-build..." | |
| if ! command -v ruby-build >/dev/null 2>&1; then | |
| git clone --depth=1 https://github.com/rbenv/ruby-build.git | |
| sudo ./ruby-build/install.sh | |
| fi | |
| echo "Building Ruby $RUBY_VERSION_FULL into toolcache..." | |
| ruby-build "$RUBY_VERSION_FULL" "$RUBY_DIR" | |
| echo "$RUBY_VERSION_FULL" > "$RUBY_DIR.version" | |
| touch "$SENTINEL" | |
| echo "Ruby $RUBY_VERSION_FULL installed at $RUBY_DIR" | |
| - name: Setup Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: ${{ env.RUBY_VERSION_SHORT }} | |
| bundler-cache: true | |
| cache-version: 0 | |
| - name: Setup Pages | |
| id: pages | |
| uses: actions/configure-pages@v4 | |
| - name: Build with Jekyll | |
| run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}" | |
| env: | |
| JEKYLL_ENV: production | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| deploy: | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-24.04 | |
| needs: build | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |