Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 63 additions & 17 deletions .github/workflows/build-and-preview-site.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,78 @@
name: Build and Preview Site

on:
pull_request:
pull_request_target:
branches: [master]
types: [opened, synchronize, reopened]
types: [opened, synchronize, reopened, closed]

permissions:
contents: write
pull-requests: write

concurrency:
group: "preview-${{ github.event.pull_request.number || github.run_id }}"
cancel-in-progress: true

jobs:
site-preview:
runs-on: ubuntu-latest
build-and-deploy-preview:
runs-on: ubuntu-24.04
steps:
- name: Checkout 🛎️
uses: actions/checkout@master
- name: Checkout PR
if: github.event.action != 'closed'
uses: actions/checkout@v6
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
persist-credentials: false
fetch-depth: 1
fetch-depth: 0

- name: Install and Build 🔧
- name: Checkout for cleanup
if: github.event.action == 'closed'
uses: actions/checkout@v6
with:
ref: gh-pages
fetch-depth: 0

- name: Install and Build
if: github.event.action != 'closed'
run: |
make setup
make build

- name: Zip Site
run: bash ./script.sh
- name: Add robots.txt for previews
if: github.event.action != 'closed'
run: |
cat > site/public/robots.txt <<'EOF'
User-agent: *
Disallow: /
EOF

- name: Deploy PR preview
if: github.event.action != 'closed'
uses: rossjrw/pr-preview-action@v1.6.3
with:
source-dir: ./site/public
preview-branch: gh-pages
umbrella-dir: pr-preview
action: auto
comment: false

- name: Comment PR with Preview URL
if: github.event.action != 'closed'
uses: marocchino/sticky-pull-request-comment@v2
with:
header: pr-preview
message: |
🚀 **Preview deployment for PR #${{ github.event.pull_request.number }}**

🌐 **Preview URL**: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr-preview/pr-${{ github.event.pull_request.number }}/

_This preview is updated automatically when commits are pushed to this PR._

- name: Upload files
uses: actions/upload-artifact@v4
- name: Cleanup PR preview on close
if: github.event.action == 'closed'
uses: rossjrw/pr-preview-action@v1.6.3
with:
name: public-dir
path: public-dir.zip
retention-days: 1
- name: Trigger Inner workflow
run: echo "triggering inner workflow"
preview-branch: gh-pages
umbrella-dir: pr-preview
action: remove
52 changes: 0 additions & 52 deletions .github/workflows/preview-site.yml

This file was deleted.