Skip to content

fix

fix #56

name: Build and Preview Site
on:
pull_request:
branches: [ master ]
types: [ opened, synchronize, reopened, closed ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
pull-requests: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Install and Build 🔧
env:
PATH_PREFIX: /recognition/pr-preview/pr-${{ github.event.pull_request.number }}
run: |
npm install
node -v
npm run build -- --prefix-paths
- name: Broken Link Check 🔗
uses: technote-space/broken-link-checker-action@v2
with:
target: ./public/**/*.html
- name: Zip Site 📦
run: bash script.sh
- name: Upload Files ⬆️
uses: actions/upload-artifact@v4
with:
name: public-dir
path: public-dir.zip
retention-days: 1
preview:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Download Pre-built Site ⬇️
uses: actions/download-artifact@v4
with:
name: public-dir
path: .
- name: Extract Site 📂
run: |
unzip -q public-dir.zip
if [ -d "public-dir" ] && [ ! -d "public" ]; then
mv public-dir public
fi
- name: Deploy Preview 🚀
if: github.event.action != 'closed'
uses: rossjrw/pr-preview-action@v1.6.3
with:
source-dir: public
preview-branch: gh-pages
umbrella-dir: pr-preview
comment: true
# 'action: auto' enables automatic deployment of previews for pull requests
action: auto
token: ${{ secrets.GITHUB_TOKEN }}
- name: Remove Preview on Close 🧹
if: github.event.action == 'closed'
uses: rossjrw/pr-preview-action@v1.6.3
with:
remove: true
preview-branch: gh-pages
umbrella-dir: pr-preview
token: ${{ secrets.GITHUB_TOKEN }}