diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml new file mode 100644 index 0000000..72b0fa7 --- /dev/null +++ b/.github/workflows/preview.yml @@ -0,0 +1,41 @@ +name: Deploy PR Preview + +on: + pull_request: + types: [opened, reopened, synchronize, closed] + +concurrency: preview-${{ github.ref }} + +jobs: + deploy-preview: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + # Set up Ruby and cache gems for faster builds + - name: Set up Ruby + if: github.event.action != 'closed' + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.2' # Match your local Ruby version + bundler-cache: true + + # Compile Jekyll with a custom baseurl pointing to the preview folder + - name: Build Jekyll Site + if: github.event.action != 'closed' + run: | + bundle install + bundle exec jekyll build --baseurl "/${{ github.event.repository.name }}/pr-preview/pr-${{ github.event.number }}" + + # Deploy the compiled static folder to GitHub Pages + - name: Deploy PR Preview to GitHub Pages + uses: rossjrw/pr-preview-action@v1 + with: + source-dir: ./_site # Default output folder for Jekyll + preview-branch: gh-pages # The branch your live GitHub Pages site serves from + umbrella-dir: pr-preview # Parent folder for previews on the gh-pages branch + action: auto