From 8dabcac45cc4577f9e5dfca59b89db3316548fd9 Mon Sep 17 00:00:00 2001 From: "Martin Hinshelwood nkdAgility.com" Date: Tue, 17 Sep 2024 15:17:18 +0100 Subject: [PATCH 1/4] Update locations --- .github/workflows/main.yaml | 258 ++++++++++++++++++------------------ 1 file changed, 126 insertions(+), 132 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 139ce95151..7fece80335 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -1,16 +1,15 @@ name: Build & Release (NKDAgility) - permissions: contents: read pull-requests: write on: push: - branches: ["main"] - tags-ignore: ["v*-*"] + branches: ['main'] + tags-ignore: ['v*-*'] pull_request: - branches: ["main"] + branches: ['main'] workflow_dispatch: inputs: ForceRelease: @@ -20,7 +19,7 @@ on: type: boolean concurrency: - group: ${{ github.workflow }}-${{ github.ref }} + group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true defaults: @@ -28,10 +27,9 @@ defaults: shell: pwsh jobs: - - # Setup & Configuration + # Setup & Configuration Setup: - name: "Setup & Configuration " + name: 'Setup & Configuration ' runs-on: ubuntu-latest outputs: GitVersion_BranchName: ${{ steps.gitversion.outputs.GitVersion_BranchName }} @@ -44,118 +42,118 @@ jobs: GitVersion_MajorMinorPatch: ${{ steps.gitversion.outputs.GitVersion_MajorMinorPatch }} nkdAgility_Ring: ${{ steps.nkdagility.outputs.Ring }} nkdAgility_AzureSitesEnvironment: ${{ steps.nkdagility.outputs.AzureSitesEnvironment }} - + steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Install GitVersion - uses: gittools/actions/gitversion/setup@v1.1.1 - with: - versionSpec: '5.x' - includePrerelease: true - - name: Execute GitVersion - id: gitversion - uses: gittools/actions/gitversion/execute@v1.1.1 - with: - useConfigFile: true - configFilePath: .github/GitVersion.yml - - uses: actions/create-github-app-token@v1 - id: app-token - with: - app-id: ${{ secrets.NKDAGILITY_BOT_APP_ID }} - private-key: ${{ secrets.NKDAGILITY_BOT_CLIENTSECRET }} - - uses: dorny/paths-filter@v3 - id: filter - with: - filters: | - content: - - 'content/**' - - name: "Build NKDAgility Outputs" - shell: pwsh - id: nkdagility - env: - GH_TOKEN: ${{ steps.app-token.outputs.token }} - run: | - # Get Branch Name - Write-Output "::group::Get Branch Name" - Write-Output "-------------------------------------------" - $branchName = "${{ github.head_ref || github.ref_name }}" - Write-Output "We are running on: $branchName!" - $branchSafeName = $branchName.Replace("/", "-") - Write-Output "branchSafeName: $branchSafeName!" - Write-Output "-------------------------------------------" - Write-Output "::endgroup::" - # Ring Setup - Write-Output "::group::Ring Control Setup" - Write-Output "-------------------------------------------" - Write-Output "Ring Control Setup" - Write-Output "-------------------------------------------" - $Ring = "Canary" - $docs_deploy_folder = "./azure-devops-migration-tools/"; - $docs_baseURL = "/learn/azure-devops-migration-tools" - switch ($Env:GitVersion_PreReleaseLabel) { - "" { - $Ring = "Production"; - $AzureSitesEnvironment = "" - $docs_baseURL = "/" - } - "Preview" { - $Ring = "Preview"; - $AzureSitesEnvironment = "preview"; - $docs_baseURL = "/preview" - } - default { - $Ring = "Canary"; - $AzureSitesEnvironment = "$branchSafeName" - $docs_baseURL = "/canary/$branchSafeName" - } - } - Write-Output "We are running for the $Ring Ring!" - echo "Ring=$Ring" >> $env:GITHUB_OUTPUT - - Write-Output "We are running for the $AzureSitesEnvironment AzureSitesEnvironment!" - echo "AzureSitesEnvironment=$AzureSitesEnvironment" >> $env:GITHUB_OUTPUT - - Write-Output "docs_baseURL=$docs_baseURL" - echo "docs_baseURL=$docs_baseURL" >> $env:GITHUB_OUTPUT - Write-Output "-------------------------------------------" - Write-Output "::endgroup::" - - uses: actions/upload-artifact@v4 - with: - name: Scripts - path: ./.powershell/** + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Install GitVersion + uses: gittools/actions/gitversion/setup@v1.1.1 + with: + versionSpec: '5.x' + includePrerelease: true + - name: Execute GitVersion + id: gitversion + uses: gittools/actions/gitversion/execute@v1.1.1 + with: + useConfigFile: true + configFilePath: .github/GitVersion.yml + - uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ secrets.NKDAGILITY_BOT_APP_ID }} + private-key: ${{ secrets.NKDAGILITY_BOT_CLIENTSECRET }} + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + content: + - 'content/**' + - name: 'Build NKDAgility Outputs' + shell: pwsh + id: nkdagility + env: + GH_TOKEN: ${{ steps.app-token.outputs.token }} + run: | + # Get Branch Name + Write-Output "::group::Get Branch Name" + Write-Output "-------------------------------------------" + $branchName = "${{ github.head_ref || github.ref_name }}" + Write-Output "We are running on: $branchName!" + $branchSafeName = $branchName.Replace("/", "-") + Write-Output "branchSafeName: $branchSafeName!" + Write-Output "-------------------------------------------" + Write-Output "::endgroup::" + # Ring Setup + Write-Output "::group::Ring Control Setup" + Write-Output "-------------------------------------------" + Write-Output "Ring Control Setup" + Write-Output "-------------------------------------------" + $Ring = "Canary" + $docs_deploy_folder = "./azure-devops-migration-tools/"; + $docs_baseURL = "/learn/azure-devops-migration-tools" + switch ($Env:GitVersion_PreReleaseLabel) { + "" { + $Ring = "Production"; + $AzureSitesEnvironment = "" + $docs_baseURL = "/" + } + "Preview" { + $Ring = "Preview"; + $AzureSitesEnvironment = "preview"; + $docs_baseURL = "/preview" + } + default { + $Ring = "Canary"; + $AzureSitesEnvironment = "$branchSafeName" + $docs_baseURL = "/canary/$branchSafeName" + } + } + Write-Output "We are running for the $Ring Ring!" + echo "Ring=$Ring" >> $env:GITHUB_OUTPUT + + Write-Output "We are running for the $AzureSitesEnvironment AzureSitesEnvironment!" + echo "AzureSitesEnvironment=$AzureSitesEnvironment" >> $env:GITHUB_OUTPUT + + Write-Output "docs_baseURL=$docs_baseURL" + echo "docs_baseURL=$docs_baseURL" >> $env:GITHUB_OUTPUT + Write-Output "-------------------------------------------" + Write-Output "::endgroup::" + - uses: actions/upload-artifact@v4 + with: + name: Scripts + path: ./.powershell/** # Setup Validator SetupSummeryStage: - name: "Build Run Data" + name: 'Build Run Data' runs-on: ubuntu-latest needs: Setup steps: - - name: "Show Summery" - if: always() - shell: pwsh - id: nkdagility-summery - run: | - $markdown = @" - ## ${{needs.Setup.outputs.GitVersion_SemVer}} (${{needs.Setup.outputs.nkdAgility_Ring}}) - ### NKDAgility - - nkdAgility_Ring: ${{needs.Setup.outputs.nkdAgility_Ring}} - - nkdAgility_AzureSitesEnvironment: ${{needs.Setup.outputs.nkdAgility_AzureSitesEnvironment}} - ### GitVersion - - GitVersion_BranchName: ${{needs.Setup.outputs.GitVersion_BranchName}} - - GitVersion_SemVer: ${{needs.Setup.outputs.GitVersion_SemVer}} - - GitVersion_PreReleaseLabel: ${{needs.Setup.outputs.GitVersion_PreReleaseLabel}} - - GitVersion_AssemblySemVer: ${{needs.Setup.outputs.GitVersion_AssemblySemVer}} - - GitVersion_InformationalVersion: ${{needs.Setup.outputs.GitVersion_InformationalVersion}} - - GitVersion_NuGetVersion: ${{needs.Setup.outputs.GitVersion_NuGetVersion}} - "@ - echo $markdown >> $Env:GITHUB_STEP_SUMMARY - - # Build Docs + - name: 'Show Summery' + if: always() + shell: pwsh + id: nkdagility-summery + run: | + $markdown = @" + ## ${{needs.Setup.outputs.GitVersion_SemVer}} (${{needs.Setup.outputs.nkdAgility_Ring}}) + ### NKDAgility + - nkdAgility_Ring: ${{needs.Setup.outputs.nkdAgility_Ring}} + - nkdAgility_AzureSitesEnvironment: ${{needs.Setup.outputs.nkdAgility_AzureSitesEnvironment}} + ### GitVersion + - GitVersion_BranchName: ${{needs.Setup.outputs.GitVersion_BranchName}} + - GitVersion_SemVer: ${{needs.Setup.outputs.GitVersion_SemVer}} + - GitVersion_PreReleaseLabel: ${{needs.Setup.outputs.GitVersion_PreReleaseLabel}} + - GitVersion_AssemblySemVer: ${{needs.Setup.outputs.GitVersion_AssemblySemVer}} + - GitVersion_InformationalVersion: ${{needs.Setup.outputs.GitVersion_InformationalVersion}} + - GitVersion_NuGetVersion: ${{needs.Setup.outputs.GitVersion_NuGetVersion}} + "@ + echo $markdown >> $Env:GITHUB_STEP_SUMMARY + + # Build Docs BuildSite: - name: "Build Site" + name: 'Build Site' runs-on: ubuntu-latest if: ${{ success() }} needs: [Setup] @@ -166,14 +164,14 @@ jobs: steps: - uses: actions/checkout@v3 with: - submodules: true # Fetch Hugo themes (true OR recursive) - fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod + submodules: true # Fetch Hugo themes (true OR recursive) + fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod - uses: cschleiden/replace-tokens@v1 with: files: '["**/*.html"]' - tokenPrefix: "#{" - tokenSuffix: "}#" - env: + tokenPrefix: '#{' + tokenSuffix: '}#' + env: GitVersion_SemVer: ${{ needs.Setup.outputs.GitVersion_SemVer }} GitVersion_AssemblySemVer: ${{ needs.Setup.outputs.GitVersion_AssemblySemVer }} GitVersion_InformationalVersion: ${{ needs.Setup.outputs.GitVersion_InformationalVersion }} @@ -182,8 +180,6 @@ jobs: - uses: igsekor/pyspelling-any@v1.0.4 id: spellcheck name: Spellcheck - - - name: Setup Hugo uses: peaceiris/actions-hugo@v3 @@ -192,31 +188,30 @@ jobs: # extended: true - name: Build - run: hugo # --minify + run: hugo --source site # --minify - uses: actions/upload-artifact@v4 with: name: Site path: ./public/**/* - + # Release to Docs Publsh: - name: "Publish Site" + name: 'Publish Site' runs-on: ubuntu-latest needs: [Setup, BuildSite] if: ${{ success() }} steps: - - name: Download a single artifact uses: actions/download-artifact@v4 with: name: Site path: ./_site - - name: "Find files" + - name: 'Find files' shell: pwsh run: | - Get-Item -Path .\ + Get-Item -Path .\ - uses: actions/create-github-app-token@v1 id: app-token @@ -237,14 +232,13 @@ jobs: deployment_environment: ${{ (needs.Setup.outputs.nkdAgility_AzureSitesEnvironment) }} azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }} - - name: "Show Summery" + - name: 'Show Summery' if: always() shell: pwsh id: nkdagility-summery run: | - $markdown = @" - ## ${{needs.Setup.outputs.GitVersion_SemVer}} (${{needs.Setup.outputs.nkdAgility_Ring}}) - Deployed to [${{steps.azureDeploy.outputs.static_web_app_url}}](${{steps.azureDeploy.outputs.static_web_app_url}}) - "@ - echo $markdown >> $Env:GITHUB_STEP_SUMMARY - \ No newline at end of file + $markdown = @" + ## ${{needs.Setup.outputs.GitVersion_SemVer}} (${{needs.Setup.outputs.nkdAgility_Ring}}) + Deployed to [${{steps.azureDeploy.outputs.static_web_app_url}}](${{steps.azureDeploy.outputs.static_web_app_url}}) + "@ + echo $markdown >> $Env:GITHUB_STEP_SUMMARY From cb194365e5858b1cdd08f1ca10ae0bf8f81416ed Mon Sep 17 00:00:00 2001 From: "Martin Hinshelwood nkdAgility.com" Date: Tue, 17 Sep 2024 17:09:05 +0100 Subject: [PATCH 2/4] Add static site config and update the build to copy the file to the right location --- .github/workflows/main.yaml | 5 +++++ staticwebapp.config.json | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 staticwebapp.config.json diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 7fece80335..1f0673bb73 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -190,6 +190,11 @@ jobs: - name: Build run: hugo --source site # --minify + - name: Copy Files + shell: pwsh + run: | + Copy-Item -Path "staticwebapp.config.json" -Destination "/public/" + - uses: actions/upload-artifact@v4 with: name: Site diff --git a/staticwebapp.config.json b/staticwebapp.config.json new file mode 100644 index 0000000000..c3d327e1b3 --- /dev/null +++ b/staticwebapp.config.json @@ -0,0 +1,22 @@ +{ + "auth": { + "identityProviders": { + "azureActiveDirectory": { + "registration": { + "openIdIssuer": "https://mynakedagility.ciamlogin.com/658c1a65-f834-4a61-b68c-91b9a7b3e481/v2.0/", + "clientId": "f18a31b9-50fb-45ea-ae5a-d904d0b19c67" + } + } + }, + "login": { + "loginRoute": "/login", + "allowedRoles": ["authenticated"] + }, + "routes": [ + { + "route": "/protected", + "allowedRoles": ["authenticated"] + } + ] + } +} From 97cf871a214dfc9fdc6871c9d4bd5b2e6e5613e0 Mon Sep 17 00:00:00 2001 From: "Martin Hinshelwood nkdAgility.com" Date: Tue, 17 Sep 2024 17:14:08 +0100 Subject: [PATCH 3/4] try this --- .github/workflows/main.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 1f0673bb73..6bc9294029 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -193,7 +193,8 @@ jobs: - name: Copy Files shell: pwsh run: | - Copy-Item -Path "staticwebapp.config.json" -Destination "/public/" + Get-ChildItem -Path "${{ github.workspace }}" -Directory | Select-Object -ExpandProperty FullName + Copy-Item -Path "${{ github.workspace }}/staticwebapp.config.json" -Destination "${{ github.workspace }}/public/" - uses: actions/upload-artifact@v4 with: From 23a07d788abf40288009e395722409a1c2d84257 Mon Sep 17 00:00:00 2001 From: "Martin Hinshelwood nkdAgility.com" Date: Tue, 17 Sep 2024 17:14:43 +0100 Subject: [PATCH 4/4] This should be better --- .github/workflows/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 6bc9294029..ef380944dc 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -194,7 +194,7 @@ jobs: shell: pwsh run: | Get-ChildItem -Path "${{ github.workspace }}" -Directory | Select-Object -ExpandProperty FullName - Copy-Item -Path "${{ github.workspace }}/staticwebapp.config.json" -Destination "${{ github.workspace }}/public/" + Copy-Item -Path "./staticwebapp.config.json" -Destination ./public/ - uses: actions/upload-artifact@v4 with: