Deploy SchemaMagic Web to GitHub Pages #18
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: Deploy SchemaMagic Web to GitHub Pages | |
| on: | |
| # Manual deployment trigger | |
| workflow_dispatch: | |
| # Deploy when web files change (bypasses CI/CD for quick updates) | |
| push: | |
| branches: [ main ] | |
| paths: | |
| - 'SchemaMagic.Web/**' | |
| - 'SchemaMagic.Core/**' | |
| - '.github/workflows/deploy-web.yml' | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| name: Deploy Web Application | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Required for Nerdbank.GitVersioning | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '9.0.x' | |
| - name: Install Nerdbank.GitVersioning | |
| run: dotnet tool install -g nbgv | |
| - name: Get Version | |
| id: nbgv | |
| run: | | |
| VERSION=$(nbgv get-version -v SimpleVersion) | |
| FULL_VERSION=$(nbgv get-version -v SemVer2) | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "fullVersion=$FULL_VERSION" >> $GITHUB_OUTPUT | |
| echo "?? Deploying SchemaMagic Web v$VERSION" | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v4 | |
| - name: Restore dependencies | |
| run: dotnet restore SchemaMagic.Web/SchemaMagic.Web.csproj | |
| - name: Publish | |
| run: dotnet publish SchemaMagic.Web/SchemaMagic.Web.csproj --configuration Release --output dist/ | |
| - name: List published files | |
| run: | | |
| echo "?? Listing published files for debugging..." | |
| echo "Contents of dist/": | |
| ls -la dist/ | |
| echo "" | |
| echo "Searching for ALL index.html files:" | |
| find dist/ -name "index.html" -type f || echo "No index.html found" | |
| echo "" | |
| echo "First 50 files in dist/": | |
| find dist/ -type f | head -50 | |
| - name: Configure for GitHub Pages | |
| run: | | |
| echo "?? Configuring for GitHub Pages..." | |
| # Base href is already "/" in index.html for custom domain (schema.magicsuite.net) | |
| # No need to change it anymore since we're using a custom domain | |
| # Add .nojekyll file to prevent GitHub Pages from processing as Jekyll site | |
| touch dist/wwwroot/.nojekyll | |
| # Copy 404.html for SPA routing | |
| cp dist/wwwroot/index.html dist/wwwroot/404.html | |
| # Ensure CNAME file is present for custom domain | |
| if [ -f "SchemaMagic.Web/wwwroot/CNAME" ]; then | |
| cp SchemaMagic.Web/wwwroot/CNAME dist/wwwroot/CNAME | |
| echo "? CNAME file copied: $(cat dist/wwwroot/CNAME)" | |
| else | |
| echo "?? Warning: CNAME file not found" | |
| fi | |
| # Add version info file | |
| echo "${{ steps.nbgv.outputs.fullVersion }}" > dist/wwwroot/version.txt | |
| date -u +'%Y-%m-%d %H:%M:%S UTC' > dist/wwwroot/deployed.txt | |
| echo "? Configuration complete" | |
| echo "?? Version: ${{ steps.nbgv.outputs.version }}" | |
| echo "?? Build size: $(du -sh dist/wwwroot | cut -f1)" | |
| echo "?? Custom domain: schema.magicsuite.net" | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: dist/wwwroot/ | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| - name: Deployment Summary | |
| run: | | |
| echo "### ?? SchemaMagic Web Deployed!" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "| Property | Value |" >> $GITHUB_STEP_SUMMARY | |
| echo "|----------|-------|" >> $GITHUB_STEP_SUMMARY | |
| echo "| ?? Version | ${{ steps.nbgv.outputs.version }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| ?? Full Version | ${{ steps.nbgv.outputs.fullVersion }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| ?? Custom Domain | https://schema.magicsuite.net |" >> $GITHUB_STEP_SUMMARY | |
| echo "| ?? GitHub Pages | ${{ steps.deployment.outputs.page_url }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| ?? Deployed | $(date -u +'%Y-%m-%d %H:%M:%S UTC') |" >> $GITHUB_STEP_SUMMARY | |
| echo "| ?? Branch | ${{ github.ref_name }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Try it now:**" >> $GITHUB_STEP_SUMMARY | |
| echo "- ?? **Custom Domain**: [schema.magicsuite.net](https://schema.magicsuite.net) ??" >> $GITHUB_STEP_SUMMARY | |
| echo "- ?? **GitHub Pages**: [${{ steps.deployment.outputs.page_url }}](${{ steps.deployment.outputs.page_url }})" >> $GITHUB_STEP_SUMMARY |