Skip to content

Merge pull request #18 from catux/dependabot/npm_and_yarn/esbuild-0.25.0 #4

Merge pull request #18 from catux/dependabot/npm_and_yarn/esbuild-0.25.0

Merge pull request #18 from catux/dependabot/npm_and_yarn/esbuild-0.25.0 #4

Workflow file for this run

name: Deploy to GitHub Pages
on:
push:
branches:
- master
workflow_dispatch: # Allows manual triggering
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout source repository
uses: actions/checkout@v4
with:
path: source
- name: Checkout destination repository
uses: actions/checkout@v4
with:
repository: catux/catux.github.io
path: destination
token: ${{ secrets.DEPLOY_PAT }} # Personal access token with repo scope
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: source/package-lock.json
- name: Install dependencies
run: |
cd source
npm ci
- name: Build site
run: |
cd source
npm run build
- name: Copy build to destination
run: |
# Remove all files from destination except .git and distribucions subdirectories
find destination -mindepth 1 -not -path '*/.git/*' -not -path '*/distribucions/catux/*' -not -name 'CNAME' -type f -delete;
# Copy all built files to destination
cp -r source/app/public/* destination/
- name: Commit and push changes
run: |
cd destination
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git add -A
# Only commit if there are changes
git diff --quiet && git diff --staged --quiet || (git commit -m "Deploy site update from source repository" && git push)