Skip to content

fix: resolve build errors and improve GitHub Actions workflow #17

fix: resolve build errors and improve GitHub Actions workflow

fix: resolve build errors and improve GitHub Actions workflow #17

Workflow file for this run

name: Deploy to GitHub Pages
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
- name: Configure npm for better reliability
run: |
npm config set fetch-retries 10
npm config set fetch-retry-mintimeout 30000
npm config set fetch-retry-maxtimeout 300000
npm config set fetch-timeout 600000
npm config set registry https://registry.npmjs.org/
npm config set maxsockets 1
npm config set prefer-offline true
- name: Clear npm cache
run: npm cache clean --force
- name: Install dependencies with retry and fallback
run: |
for i in {1..5}; do
echo "Attempt $i of 5..."
if npm ci --legacy-peer-deps --no-audit --no-fund --verbose; then
echo "Dependencies installed successfully!"
break
else
echo "Attempt $i failed"
if [ $i -lt 5 ]; then
echo "Waiting 60 seconds before retry..."
sleep 60
echo "Clearing npm cache..."
npm cache clean --force
else
echo "All attempts failed. Trying with npm install as fallback..."
npm install --legacy-peer-deps --no-audit --no-fund
fi
fi
done
- name: Build project
run: npm run build:production
env:
NODE_ENV: production
CI: true
- name: Add .nojekyll file
run: |
mkdir -p out
touch out/.nojekyll
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/main'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./out
# Enable Jekyll processing to be disabled
enable_jekyll: false
# Add CNAME if using custom domain
# cname: your-domain.com