Skip to content

Deploy Portfolio

Deploy Portfolio #345

Workflow file for this run

# ====================================================================
# Portfolio Template - Automated Deployment
# ====================================================================
# This workflow automatically builds and deploys your portfolio to
# GitHub Pages when you push changes.
#
# 🌟 FOR TEMPLATE USERS:
# - Triggers on push to 'main' branch (default)
# - Just push your resume.yaml changes and it auto-deploys!
# - No local installation of npm, Python, or RenderCV needed
#
# 🌿 FOR TEMPLATE OWNER (subhayu99):
# - Triggers on 'main' and 'personal' branches
# - Automatically skips deployment on main (template updates only)
# - Deploys only from 'personal' branch (actual portfolio)
#
# 📚 Documentation:
# - Branch Workflow: See BRANCH_WORKFLOW.md
# - Template Users: See README.md
# ====================================================================
name: Deploy Portfolio
on:
push:
branches: [ main, personal ]
pull_request:
branches: [ main, personal ]
workflow_dispatch:
inputs:
force_refresh:
description: 'Bypass build-time API caches (PyPI + GitHub stats). Used by the daily/weekly refresh workflows.'
type: boolean
required: false
default: false
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
# Skip this job if running on template repo's main branch
if: github.repository != 'subhayu99/subhayu99.github.io' || github.ref != 'refs/heads/main'
steps:
- name: 📥 Checkout repository
uses: actions/checkout@v4
- name: 🔧 Setup Node.js 20
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: 🐍 Setup Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: 📦 Install RenderCV
run: pip install "rendercv[full]"
- name: 📦 Install npm dependencies
run: npm ci
- name: 🔍 Type check TypeScript
run: npm run type-check
continue-on-error: true
- name: 🎨 Setup template files (if needed)
run: |
echo "Setting up template configuration files..."
# Copy example files if user hasn't created their own
if [ ! -f "resume.yaml" ]; then
echo "⚠️ No resume.yaml found - using example resume"
cp resume.yaml.example resume.yaml
fi
# Only copy neofetch files as fallbacks (these are optional customizations)
# styled_name.txt and manifest.json will be auto-generated by the build script
if [ ! -f "client/public/data/neofetch.txt" ]; then
echo "📝 Copying neofetch.txt from example"
cp client/public/data/neofetch.txt.example client/public/data/neofetch.txt
fi
if [ ! -f "client/public/data/neofetch-small.txt" ]; then
echo "📝 Copying neofetch-small.txt from example"
cp client/public/data/neofetch-small.txt.example client/public/data/neofetch-small.txt
fi
echo "✅ Template setup complete!"
- name: 🔧 Compute base path and deployment URL
id: compute-base-path
run: |
# Extract repository name from GITHUB_REPOSITORY (format: owner/repo)
REPO_NAME="${GITHUB_REPOSITORY#*/}"
REPO_OWNER="${GITHUB_REPOSITORY%/*}"
# Check if this is a user/org GitHub Pages site (username.github.io)
if [ "$REPO_NAME" = "${REPO_OWNER}.github.io" ]; then
# User/org site: use root path
BASE_PATH="/"
SITE_URL="https://${REPO_OWNER}.github.io"
echo "📍 Detected user/org site: ${REPO_NAME}"
else
# Project site: use /repo-name/ path
BASE_PATH="/${REPO_NAME}/"
SITE_URL="https://${REPO_OWNER}.github.io/${REPO_NAME}"
echo "📍 Detected project site: ${REPO_NAME}"
fi
echo "🔗 Base path: ${BASE_PATH}"
echo "🌐 Site URL: ${SITE_URL}"
echo "BASE_PATH=${BASE_PATH}" >> $GITHUB_OUTPUT
echo "SITE_URL=${SITE_URL}" >> $GITHUB_OUTPUT
- name: 🏗️ Build application
# Note: npm run build now automatically generates resume files if resume.yaml exists
run: npm run build
env:
VITE_BASE_PATH: ${{ steps.compute-base-path.outputs.BASE_PATH }}
VITE_SITE_URL: ${{ steps.compute-base-path.outputs.SITE_URL }}
# scripts/fetch-stats.js needs auth for /search/code (any token
# works) and /traffic/* (owner-only, will gracefully no-op if the
# workflow's GITHUB_TOKEN lacks `administration: read`).
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Set to 1 by the daily/weekly refresh workflows to bypass the
# cache helpers. On normal pushes this stays unset, so each deploy
# reuses fresh JSON from the previous run / the live site.
FORCE_REFRESH: ${{ github.event.inputs.force_refresh == 'true' && '1' || '' }}
# Cloudflare Web Analytics beacon token. Optional — when unset, the
# build no-ops the analytics plugin and the template's tight CSP
# stays in place. Set as a repo secret to enable tracking.
VITE_CF_BEACON_TOKEN: ${{ secrets.VITE_CF_BEACON_TOKEN }}
- name: ⚙️ Configure GitHub Pages
uses: actions/configure-pages@v4
- name: 📤 Upload build artifact
uses: actions/upload-pages-artifact@v3
with:
path: './dist/public'
deploy:
name: 🚀 Deploy to GitHub Pages
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
# Skip this job if running on template repo's main branch
if: github.repository != 'subhayu99/subhayu99.github.io' || github.ref != 'refs/heads/main'
steps:
- name: 🌐 Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
- name: ✅ Deployment complete
run: |
echo "🎉 Your portfolio is now live!"
echo "🔗 URL: ${{ steps.deployment.outputs.page_url }}"
echo ""
echo "To update your portfolio, just push changes to the personal branch."
echo "The site will automatically rebuild and redeploy!"