Skip to content

Fix/favicon missing pages #406

Fix/favicon missing pages

Fix/favicon missing pages #406

Workflow file for this run

name: PR Preview to GitHub Pages
on:
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
jobs:
deploy-preview:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
pages: write
id-token: write
steps:
- name: Checkout PR branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 1
- name: Set up Node.js
if: env.BUILD_REQUIRED == 'true' # Set this environment variable in the repository settings if a build is needed
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm" # Cache dependencies for faster builds
- name: Install dependencies
if: env.BUILD_REQUIRED == 'true'
run: npm ci # Use npm ci for reproducible builds
- name: Build project
if: env.BUILD_REQUIRED == 'true'
run: npm run build # Replace with your build command (e.g., `hugo`, `vite build`, etc.)
env:
BASE_URL: /${{ github.repository }}/pr-preview/pr-${{ github.event.pull_request.number }}/
- name: Copy files to preview folder
run: |
mkdir -p preview/pr-${{ github.event.pull_request.number }}
cp -r ./*.html ./styles ./assets preview/pr-${{ github.event.pull_request.number }}/ || echo "Copy fallback"
# Copies from `dist` if a build step exists, otherwise copies all files (excluding .git, .github)
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
personal_token: ${{ secrets.DEPLOY_PAT }}
external_repository: Mastercoder0406/CodeClip
publish_dir: ./preview/pr-${{ github.event.pull_request.number }}
publish_branch: gh-pages
destination_dir: pr-preview/pr-${{ github.event.pull_request.number }}
keep_files: false # Clean up old files to avoid bloat
user_name: "github-actions[bot]"
user_email: "github-actions[bot]@users.noreply.github.com"
- name: Comment PR with preview URL
uses: marocchino/sticky-pull-request-comment@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
header: preview-url
message: |
🚀 **PR Preview deployed!**
📍 **Preview URL:** https://opensource-society.github.io/CodeClip/pr-preview/pr-${{ github.event.pull_request.number }}/
The preview will be available in a few minutes after the deployment completes.