Merge pull request #14 from dougdevitre/claude/fix-structure-deployme… #10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build & Deploy | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm ci | |
| # Cache poppler-utils to avoid re-installing every build | |
| - name: Install poppler-utils | |
| run: | | |
| if ! command -v pdftotext &>/dev/null; then | |
| sudo apt-get update && sudo apt-get install -y poppler-utils | |
| else | |
| echo "pdftotext already available" | |
| fi | |
| # Restore build cache (parsed profiles, enhanced copies) | |
| - name: Restore build cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: .cache | |
| key: build-cache-${{ hashFiles('input/*.pdf', 'input/profile.json') }} | |
| restore-keys: | | |
| build-cache- | |
| # Incremental parse — skip if PDF unchanged (cache handles this) | |
| - name: Parse LinkedIn PDF | |
| run: | | |
| PDF=$(find input/ -name "*.pdf" -type f | head -1) | |
| if [ -n "$PDF" ]; then | |
| echo "Found PDF: $PDF" | |
| npx ts-node cli/parse-linkedin.ts "$PDF" input/ | |
| else | |
| echo "No PDF found in input/ — using existing profile.json" | |
| fi | |
| # Enhance with Claude if API key is available (cache skips if unchanged) | |
| - name: Enhance profile with Claude | |
| if: env.ANTHROPIC_API_KEY != '' | |
| env: | |
| ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} | |
| run: | | |
| if [ -f input/profile.json ]; then | |
| npx ts-node cli/enhance-profile.ts input/profile.json input/profile.json | |
| fi | |
| # Generate config if it doesn't exist | |
| - name: Generate config | |
| run: | | |
| if [ ! -f config.json ] && [ -f input/profile.json ]; then | |
| npx ts-node cli/generate-config.ts input/profile.json config.json | |
| fi | |
| # Build minified assets + generate site | |
| - name: Build assets | |
| run: npm run build:assets | |
| - name: Build site | |
| run: | | |
| if [ -f input/profile.json ] && [ -f config.json ]; then | |
| npx ts-node cli/generate-site.ts input/profile.json config.json site/ | |
| elif [ -f example/profile.json ] && [ -f example/config.json ]; then | |
| echo "No profile data — building with example data" | |
| npx ts-node cli/generate-site.ts example/profile.json example/config.json site/ | |
| else | |
| echo "❌ No profile data found" | |
| exit 1 | |
| fi | |
| - name: Verify build output | |
| run: | | |
| if [ ! -f site/index.html ]; then | |
| echo "❌ site/index.html not found — build failed" | |
| exit 1 | |
| fi | |
| echo "✅ site/index.html exists ($(wc -c < site/index.html) bytes)" | |
| for f in base.css theme.css app.js .nojekyll robots.txt; do | |
| if [ -f "site/$f" ]; then | |
| echo " ✓ $f: $(wc -c < "site/$f") bytes" | |
| else | |
| echo " ✗ $f: missing" | |
| fi | |
| done | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: site/ | |
| deploy: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |