Skip to content
Merged
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
24 changes: 17 additions & 7 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: PR Preview Workflow

on:
pull_request:
pull_request_target:
types:
- opened
- synchronize
Expand All @@ -13,7 +13,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Setup Julia
uses: julia-actions/setup-julia@v2
Expand Down Expand Up @@ -46,26 +48,33 @@ jobs:
_freeze/
key: ${{ runner.os }}-primes-${{ github.run_id }}

- name: Checkout gh-pages branch
uses: actions/checkout@v3
with:
ref: gh-pages
path: gh-pages

- name: Deploy Preview to GitHub Pages
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
PREVIEW_DIR="pr-previews/${PR_NUMBER}"
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git clone --depth 1 --branch gh-pages https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} gh-pages
mkdir -p gh-pages/${PREVIEW_DIR}
cp -r _site/* gh-pages/${PREVIEW_DIR}
cd gh-pages
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "Deploy preview for PR ${PR_NUMBER}"
git push
env:
GH_PAT: ${{ secrets.GH_PAT }}

delete-preview-directory:
if: github.event.action == 'closed' || github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout gh-pages branch
uses: actions/checkout@v4
uses: actions/checkout@v3
with:
ref: gh-pages

Expand Down Expand Up @@ -125,4 +134,5 @@ jobs:
repo: context.repo.repo,
body: commentBody,
});
}
}