diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000..32fdfc4 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,54 @@ +name: Build and Test + +# Run on PRs and pushes to any branch +on: + push: + branches: [ '**' ] + pull_request: + branches: [ main ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 9.0.x + + - name: Restore dependencies + run: dotnet restore + + - name: Build + run: dotnet build --configuration Release --no-restore + + - name: Test + run: dotnet test --no-build --verbosity normal --configuration Release + + - name: Publish + run: dotnet publish InGeorgianLari.csproj -c Release -o artifacts --nologo + + # Upload build artifacts for inspection + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: build-artifacts-${{ github.sha }} + path: artifacts/ + retention-days: 7 + + # Add build status comment to PR + - name: Comment PR + if: github.event_name == 'pull_request' + uses: actions/github-script@v7 + with: + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: 'โœ… Build succeeded! The Blazor WASM app compiled successfully.' + }) \ No newline at end of file diff --git a/.github/workflows/deploy-preview.yml b/.github/workflows/deploy-preview.yml new file mode 100644 index 0000000..22995af --- /dev/null +++ b/.github/workflows/deploy-preview.yml @@ -0,0 +1,87 @@ +name: Deploy Preview to GitHub Pages + +# Allow manual trigger from any branch +on: + workflow_dispatch: + inputs: + environment: + description: 'Deployment environment name' + required: false + default: 'preview' + type: string + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment +concurrency: + group: "pages-preview" + cancel-in-progress: true + +jobs: + # Build job + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 9.0.x + + - name: Restore dependencies + run: dotnet restore + + - name: Build + run: dotnet build --configuration Release --no-restore + + - name: Publish + run: dotnet publish InGeorgianLari.csproj -c Release -o release --nologo + + # Change base tag in index.html to match GitHub Pages subdirectory + - name: Change base tag + run: sed -i 's///g' release/wwwroot/index.html + + # Copy index.html to 404.html to handle SPA routing + - name: Copy index.html to 404.html + run: cp release/wwwroot/index.html release/wwwroot/404.html + + # Add .nojekyll file to tell GitHub Pages to not process files + - name: Add .nojekyll file + run: touch release/wwwroot/.nojekyll + + # Add branch info file for preview identification + - name: Add branch info + run: | + echo "Branch: ${{ github.ref_name }}" > release/wwwroot/branch-info.txt + echo "Commit: ${{ github.sha }}" >> release/wwwroot/branch-info.txt + echo "Deployed: $(date -u +"%Y-%m-%d %H:%M:%S UTC")" >> release/wwwroot/branch-info.txt + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: release/wwwroot + + # Deployment job + deploy: + environment: + name: ${{ inputs.environment || 'preview' }} + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 + + - name: Print deployment info + run: | + echo "๐Ÿš€ Preview deployed!" + echo "๐Ÿ“ URL: ${{ steps.deployment.outputs.page_url }}" + echo "๐ŸŒฟ Branch: ${{ github.ref_name }}" + echo "๐Ÿ“ Commit: ${{ github.sha }}" \ No newline at end of file diff --git a/.github/workflows/deploy-to-github-pages.yml b/.github/workflows/deploy-to-github-pages.yml new file mode 100644 index 0000000..4dfe9e6 --- /dev/null +++ b/.github/workflows/deploy-to-github-pages.yml @@ -0,0 +1,77 @@ +name: Deploy to GitHub Pages + +# Run workflow on every push to main branch +on: + push: + branches: [ main ] + # Allow manual trigger + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + # Build job + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 9.0.x + + - name: Restore dependencies + run: dotnet restore + + - name: Build + run: dotnet build --configuration Release --no-restore + + - name: Publish + run: dotnet publish InGeorgianLari.csproj -c Release -o release --nologo + + # Change base tag in index.html to match GitHub Pages subdirectory + - name: Change base tag + run: | + # Check if custom domain exists + if [ -f "wwwroot/CNAME" ]; then + echo "Custom domain detected, keeping base href as /" + else + echo "No custom domain, updating base href for GitHub Pages subdirectory" + sed -i 's///g' release/wwwroot/index.html + fi + + # Copy index.html to 404.html to handle SPA routing + - name: Copy index.html to 404.html + run: cp release/wwwroot/index.html release/wwwroot/404.html + + # Add .nojekyll file to tell GitHub Pages to not process files + - name: Add .nojekyll file + run: touch release/wwwroot/.nojekyll + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: release/wwwroot + + # Deployment job + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 \ No newline at end of file diff --git a/Layout/MainLayout.razor b/Layout/MainLayout.razor index 76eb725..b4f1ca1 100644 --- a/Layout/MainLayout.razor +++ b/Layout/MainLayout.razor @@ -1,16 +1,127 @@ ๏ปฟ@inherits LayoutComponentBase +@inject IJSRuntime JSRuntime + +
+
+
-
- About -
-
@Body
+ +@code { + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + await JSRuntime.InvokeVoidAsync("createParticles", "global-particles"); + } + } +} + + diff --git a/Layout/NavMenu.razor b/Layout/NavMenu.razor index 4535372..e47617c 100644 --- a/Layout/NavMenu.razor +++ b/Layout/NavMenu.razor @@ -1,6 +1,6 @@ ๏ปฟ