Skip to content
Closed
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
14 changes: 8 additions & 6 deletions .github/workflows/pr-preview.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
name: PR Preview to GitHub Pages

on:
pull_request:
pull_request_target:
types: [opened, synchronize, reopened]
branches:
- main

jobs:
deploy-preview:
runs-on: ubuntu-latest
if: github.event.pull_request.head.repo.full_name == github.repository
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout PR branch
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 1

- name: Set up Node.js
Expand All @@ -24,9 +28,7 @@ jobs:
- name: Copy files to preview folder
run: |
mkdir -p preview/pr-${{ github.event.pull_request.number }}
cp -r * preview/pr-${{ github.event.pull_request.number }}/
rm -rf preview/pr-${{ github.event.pull_request.number }}/.git
rm -rf preview/pr-${{ github.event.pull_request.number }}/.github
rsync -av --exclude 'preview' --exclude '.git' --exclude '.github' ./ preview/pr-${{ github.event.pull_request.number }}/

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
Expand All @@ -43,4 +45,4 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
header: preview-url
message: |
🚀 PR Preview: https://opensource-society.github.io/${{ github.repository }}/pr-preview/pr-${{ github.event.pull_request.number }}/index.html
🚀 PR Preview: PR Preview: https://opensource-society.github.io/${{ github.repository }}/pr-preview/pr-${{ github.event.pull_request.number }}/index.html
Loading