Merge pull request #727 from codemonkey85/dev #496
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 to GitHub Pages | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [ main ] | |
| paths-ignore: | |
| - "**.md" | |
| - "**.ps1" | |
| - ".editorconfig" | |
| - "TestFiles/*" | |
| - '**/*.gitignore' | |
| - '**/*.gitattributes' | |
| - '**/*.yml' | |
| jobs: | |
| deploy: | |
| name: Deploy to GitHub Pages | |
| # use ubuntu-latest image to run steps on | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| permissions: | |
| contents: write | |
| pages: write | |
| id-token: write | |
| steps: | |
| # uses GitHub's checkout action to checkout code from the release branch | |
| - name: Checkout code | |
| uses: actions/checkout@v6.0.2 | |
| with: | |
| persist-credentials: true | |
| # sets up .NET SDK | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5.2.0 | |
| with: | |
| global-json-file: ./global.json | |
| - name: Install WASM workload | |
| run: dotnet workload install wasm-tools | |
| - name: Restore dependencies | |
| run: dotnet restore Pkmds.Web/Pkmds.Web.csproj | |
| # Compute the version number once to ensure consistency | |
| - name: Compute version number | |
| id: version | |
| run: echo "VERSION=$(date -u '+%Y.%m.%d%H.%M%S')" >> $GITHUB_OUTPUT | |
| # publishes Blazor project to the release-folder with the computed version | |
| - name: Publish .NET Project | |
| run: dotnet publish Pkmds.Web/Pkmds.Web.csproj -c Release -o release --nologo /p:Version=${{ steps.version.outputs.VERSION }} | |
| # Create and push git tag with the version number | |
| - name: Create and push tag | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag -a "${{ steps.version.outputs.VERSION }}" -m "Release ${{ steps.version.outputs.VERSION }}" | |
| git push origin "${{ steps.version.outputs.VERSION }}" | |
| # copy index.html to 404.html to serve the same file when a file is not found | |
| - 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 treat this as a Jekyll project. (Allow files and folders starting with an underscore) | |
| - name: Add .nojekyll file | |
| run: touch release/wwwroot/.nojekyll | |
| - name: Update version | |
| uses: datamonsters/replace-action@v2 | |
| with: | |
| files: 'release/wwwroot/service-worker.published.js' | |
| replacements: '%%CACHE_VERSION%%=${{ github.run_id }}' | |
| - name: Configure GitHub Pages | |
| uses: actions/configure-pages@v6.0.0 | |
| - name: Upload Pages artifact | |
| uses: actions/upload-pages-artifact@v5.0.0 | |
| with: | |
| path: release/wwwroot | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v5.0.0 | |
| deploy_functions: | |
| name: Deploy Azure Functions | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6.0.2 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5.2.0 | |
| with: | |
| global-json-file: ./global.json | |
| - name: Publish Functions | |
| run: dotnet publish Pkmds.Functions/Pkmds.Functions.csproj -c Release -o functions-publish --nologo | |
| - name: Zip publish output | |
| run: cd functions-publish && zip -r ../functions.zip . | |
| - name: Azure login | |
| uses: azure/login@v1 | |
| with: | |
| creds: ${{ secrets.AZURE_CREDENTIALS }} | |
| - name: Deploy to Azure Functions | |
| run: | | |
| az functionapp deployment source config-zip \ | |
| --name pkmds-functions \ | |
| --resource-group pkmds-bug-reports \ | |
| --src functions.zip |