name: Third-Party Repository Profiling

on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master
jobs:
  build_n_profile:
    if: "!contains(github.event.commits[0].message, '[ci skip]')"
    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@v3
      with:
        fetch-depth: 5
        path: jekyll
    - name: Checkout Third-Party Repository
      uses: actions/checkout@v3
      with:
        repository: ashmaroli/tomjoht.github.io
        path: sandbox
    - name: Set up Ruby
      uses: ruby/setup-ruby@v1
      with:
        ruby-version: 2.7
        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
