diff --git a/.github/workflows/jekyll.yml b/.github/workflows/jekyll.yml index 501686b..933239f 100644 --- a/.github/workflows/jekyll.yml +++ b/.github/workflows/jekyll.yml @@ -16,7 +16,7 @@ on: # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: - contents: read + contents: write pages: write id-token: write @@ -27,8 +27,8 @@ concurrency: cancel-in-progress: false jobs: - # Build job - build: + # Build and deploy job + build-and-deploy: runs-on: ubuntu-latest steps: - name: Checkout @@ -40,26 +40,16 @@ jobs: 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 - - name: Setup Pages - id: pages - uses: actions/configure-pages@v5 - name: Build with Jekyll # Outputs to the './_site' directory by default - run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}" + run: bundle exec jekyll build env: JEKYLL_ENV: production - - 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 - steps: - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 + uses: peaceiris/actions-gh-pages@v4 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./_site + publish_branch: gh-pages + # Keep existing files (preserves PR preview directories) + keep_files: true diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml new file mode 100644 index 0000000..f5052b6 --- /dev/null +++ b/.github/workflows/pr-preview.yml @@ -0,0 +1,45 @@ +# Workflow for deploying PR previews to GitHub Pages +name: Deploy PR Preview + +on: + pull_request: + types: + - opened + - reopened + - synchronize + - closed + +# Sets permissions of the GITHUB_TOKEN +permissions: + contents: write + pull-requests: write + +# Prevent concurrent deployments for the same PR +concurrency: preview-${{ github.ref }} + +jobs: + deploy-preview: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + if: github.event.action != 'closed' + + - name: Setup Ruby + uses: ruby/setup-ruby@4a9ddd6f338a97768b8006bf671dfbad383215f4 + if: github.event.action != 'closed' + with: + ruby-version: '3.1' + bundler-cache: true + cache-version: 0 + + - name: Build with Jekyll + if: github.event.action != 'closed' + run: bundle exec jekyll build --baseurl "/pr-preview/pr-${{ github.event.number }}" + env: + JEKYLL_ENV: production + + - name: Deploy PR Preview + uses: rossjrw/pr-preview-action@v1.6.3 + with: + source-dir: ./_site/