Skip to content

Changes made

Changes made #5

Workflow file for this run

name: Deploy to GitHub Pages
on:
push:
branches: [ main ]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
- name: Setup Node.js ⚙️
uses: actions/setup-node@v3
with:
node-version: '19'
cache: 'npm'
- name: Install dependencies 📦
run: npm ci
- name: Build 🔧
run: NODE_ENV=production npm run build
- name: Create .nojekyll file 📄
run: touch dist/.nojekyll
- name: Create MIME types configuration 📄
run: |
echo '# MIME types configuration
*.jsx application/javascript
*.js application/javascript
' > dist/.htaccess
- name: Prepare for deployment
run: |
# Create an empty public directory in case it doesn't exist
mkdir -p public
# Copy all images to dist to ensure they're available
cp -r public/* dist/ || true
# Create 404.html for GitHub Pages SPA routing
cat > dist/404.html << 'EOL'
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hassan Shahzad | Portfolio</title>
<script type="text/javascript">
// Single Page Apps for GitHub Pages
// MIT License
// https://github.com/rafgraph/spa-github-pages
var pathSegmentsToKeep = 1;
var l = window.location;
l.replace(
l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') +
l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' +
l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') +
(l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') +
l.hash
);
</script>
</head>
<body>
</body>
</html>
EOL
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: dist
branch: gh-pages