name: Third-Party Repository Profiling

on:
  workflow_dispatch:

jobs:
  build_n_profile:
    runs-on: "ubuntu-latest"
    env:
      BUNDLE_GEMFILE: "sandbox/Gemfile"
      BUNDLE_PATH: "vendor/bundle"
      BUNDLE_JOBS: 4
      BUNDLE_RETRY: 3
    steps:
    - name: Checkout Jekyll
      uses: actions/checkout@v4
      with:
        fetch-depth: 5
        path: jekyll
    - name: Checkout Third-Party Repository
      uses: actions/checkout@v4
      with:
        repository: ashmaroli/tomjoht.github.io
        path: sandbox
    - name: Set up Ruby
      uses: ruby/setup-ruby@v1
      with:
        ruby-version: 3.4
        bundler-cache: true
    - name: Run Jekyll Build 3 times
      run: |
        bundle exec jekyll build -s sandbox -d sandbox/_site --trace
        bundle exec jekyll build -s sandbox -d sandbox/_site --trace
        bundle exec jekyll build -s sandbox -d sandbox/_site --trace
    - name: Memory Analysis of Jekyll Build
      run: bundle exec ruby jekyll/.github/workflows/actions/memprof.rb sandbox
