Skip to content

Commit c291def

Browse files
authored
Trying to get CD on Website without always pushing whole app to Winget (#2842)
This pull request updates the `.github/workflows/main.yml` file to refine the conditions under which various workflow jobs are executed. The changes focus on clarifying and adjusting the release logic, ensuring that jobs are only triggered under appropriate circumstances, and improving readability with comments. ### Workflow logic improvements: * Updated the `RunRelease` condition to trigger only when `ForceRelease` is true or source code changes are detected, and removed unnecessary checks for documentation changes in the `Preview` ring. (`[.github/workflows/main.ymlR227-R262](diffhunk://#diff-7829468e86c1cc5d5133195b5cb48e1ff6c75e3e9203777f6b2e379d9e4882b3R227-R262)`) * Modified the build job to run only when source code changes are detected, simplifying the condition. (`[.github/workflows/main.ymlL351-R354](diffhunk://#diff-7829468e86c1cc5d5133195b5cb48e1ff6c75e3e9203777f6b2e379d9e4882b3L351-R354)`) * Adjusted the release jobs (`Release to Marketplace`, `Release to Chocolatey`, `Release to Winget`) to ensure they only run when the app was released, with additional checks for the production environment in the marketplace release. (`[[1]](diffhunk://#diff-7829468e86c1cc5d5133195b5cb48e1ff6c75e3e9203777f6b2e379d9e4882b3L583-R589)`, `[[2]](diffhunk://#diff-7829468e86c1cc5d5133195b5cb48e1ff6c75e3e9203777f6b2e379d9e4882b3L612-R619)`, `[[3]](diffhunk://#diff-7829468e86c1cc5d5133195b5cb48e1ff6c75e3e9203777f6b2e379d9e4882b3L636-R644)`) * Added comments to clarify the purpose of each condition, improving maintainability and readability across all affected jobs. (`[[1]](diffhunk://#diff-7829468e86c1cc5d5133195b5cb48e1ff6c75e3e9203777f6b2e379d9e4882b3L501-R505)`, `[[2]](diffhunk://#diff-7829468e86c1cc5d5133195b5cb48e1ff6c75e3e9203777f6b2e379d9e4882b3L568-R573)`, `[[3]](diffhunk://#diff-7829468e86c1cc5d5133195b5cb48e1ff6c75e3e9203777f6b2e379d9e4882b3R665)`)
2 parents 9ec2e1a + 44f7e6b commit c291def

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

.github/workflows/main.yml

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -224,40 +224,42 @@ jobs:
224224
Write-Output "branchSafeName: $branchSafeName!"
225225
Write-Output "-------------------------------------------"
226226
Write-Output "::endgroup::"
227+
227228
# Ring Setup
228229
Write-Output "::group::Ring Control Setup"
229230
Write-Output "-------------------------------------------"
230231
Write-Output "Ring Control Setup"
231232
Write-Output "-------------------------------------------"
232233
$Ring = "${{ steps.RingDetection.outputs.Ring }}"
233234
$WingetApplicationId = "nkdagility.azure-devops-migration-tools"
234-
$RunCodeRelease = 'false'
235-
$RunDocsRelease = 'false'
235+
236236
switch ("${{ steps.RingDetection.outputs.Ring }}") {
237237
"Production" {
238238
$WingetApplicationId = "nkdagility.azure-devops-migration-tools";
239239
$AzureSitesEnvironment = ""
240-
$RunRelease = 'true'
240+
# Production: Release app when ForceRelease OR src changed
241+
$RunRelease = ( ('${{ inputs.ForceRelease }}' -eq 'true' ) -or ('${{ steps.filter.outputs.src }}' -eq 'true') )
241242
}
242243
"Preview" {
243244
$WingetApplicationId = "nkdagility.azure-devops-migration-tools.Preview";
244245
$AzureSitesEnvironment = "preview";
245-
$RunRelease = ( ('${{ inputs.ForceRelease }}' -eq 'true' ) -or ('${{ steps.filter.outputs.src }}' -eq 'true') -or ('${{ steps.filter.outputs.docs }}' -eq 'true') )
246+
# Preview: Release app when ForceRelease OR src changed
247+
$RunRelease = ( ('${{ inputs.ForceRelease }}' -eq 'true' ) -or ('${{ steps.filter.outputs.src }}' -eq 'true') )
246248
}
247249
default {
248250
$WingetApplicationId = "nkdagility.azure-devops-migration-tools.Canary";
249251
$AzureSitesEnvironment = "${{ steps.RingDetection.outputs.Ring }}-${{ github.event.pull_request.number }}".ToLower()
250252
$RunRelease = 'false'
251253
}
252254
}
255+
253256
Write-Output "We are running for the $Ring Ring!"
254257
echo "Ring=$Ring" >> $env:GITHUB_OUTPUT
255258
Write-Output "We are focused on Winget ID $WingetApplicationId!"
256259
echo "WingetApplicationId=$WingetApplicationId" >> $env:GITHUB_OUTPUT
257-
258260
Write-Output "We are running for the $AzureSitesEnvironment AzureSitesEnvironment!"
259261
echo "AzureSitesEnvironment=$AzureSitesEnvironment" >> $env:GITHUB_OUTPUT
260-
Write-Output "RunRelease=$RunRelease"
262+
Write-Output "RunRelease=$RunRelease (App releases when ForceRelease OR src changed)"
261263
echo "RunRelease=$RunRelease" >> $env:GITHUB_OUTPUT
262264
Write-Output "-------------------------------------------"
263265
Write-Output "::endgroup::"
@@ -348,7 +350,9 @@ jobs:
348350
name: "Build, Test, Sonar Cloud Analysis, & Package"
349351
runs-on: windows-latest
350352
needs: Setup
351-
if: ${{ success() && ( needs.Setup.outputs.HasChanged_src == 'true' || needs.Setup.outputs.nkdAgility_RunRelease == 'true' ) }}
353+
# Build app only when src has changed
354+
if: ${{ success() && (needs.Setup.outputs.HasChanged_src == 'true' || needs.Setup.outputs.HasChanged_automation == 'true') }}
355+
352356
env:
353357
solution: '**/*.sln'
354358
buildPlatform: 'Any CPU'
@@ -498,7 +502,8 @@ jobs:
498502
GitVersion_NuGetVersion: ${{ needs.Setup.outputs.GitVersion_NuGetVersion }}
499503
GitVersion_PreReleaseLabel: ${{ needs.Setup.outputs.GitVersion_PreReleaseLabel }}
500504
needs: [build, Setup, BuildDocs]
501-
if: ${{ success() && ( needs.Setup.outputs.nkdAgility_RunRelease == 'true' ) }}
505+
# Release app when RunRelease is true (ForceRelease OR src changed)
506+
if: ${{ success() && needs.Setup.outputs.nkdAgility_RunRelease == 'true' }}
502507
steps:
503508
- uses: actions/download-artifact@v4
504509
with:
@@ -565,7 +570,8 @@ jobs:
565570
env:
566571
GitVersion_SemVer: ${{ needs.Setup.outputs.GitVersion_SemVer }}
567572
needs: [GitHubRelease, Setup]
568-
if: ${{ success() && ( needs.Setup.outputs.nkdAgility_RunRelease == 'true' ) }}
573+
# Only when app was released
574+
if: ${{ success() && needs.Setup.outputs.nkdAgility_RunRelease == 'true' }}
569575
steps:
570576
- name: Create Deployment on elmah.io
571577
uses: elmahio/github-create-deployment-action@v1
@@ -580,7 +586,8 @@ jobs:
580586
name: "Release to Marketplace"
581587
runs-on: ubuntu-latest
582588
needs: [Setup, GitHubRelease]
583-
if: ${{ success() && ( needs.Setup.outputs.nkdAgility_Ring == 'Production' ) }}
589+
# Only release to marketplace when app was released and it's production
590+
if: ${{ success() && needs.Setup.outputs.nkdAgility_RunRelease == 'true' && needs.Setup.outputs.nkdAgility_Ring == 'Production' }}
584591
steps:
585592
- name: Checkout
586593
uses: actions/checkout@v4
@@ -609,7 +616,8 @@ jobs:
609616
name: "Release to Chocolatey"
610617
runs-on: windows-latest
611618
needs: [Setup, GitHubRelease]
612-
if: ${{ success() && ( needs.Setup.outputs.nkdAgility_RunRelease == 'true' ) }}
619+
# Only when app was released
620+
if: ${{ success() && needs.Setup.outputs.nkdAgility_RunRelease == 'true' }}
613621
steps:
614622
- uses: actions/download-artifact@v4
615623
with:
@@ -633,7 +641,8 @@ jobs:
633641
name: "Release to Winget"
634642
runs-on: windows-latest
635643
needs: [Setup, GitHubRelease]
636-
if: ${{ success() && ( needs.Setup.outputs.nkdAgility_RunRelease == 'true' ) }}
644+
# Only when app was released
645+
if: ${{ success() && needs.Setup.outputs.nkdAgility_RunRelease == 'true' }}
637646
steps:
638647
- name: Checkout
639648
uses: actions/checkout@v4
@@ -654,6 +663,7 @@ jobs:
654663
name: "Release to Docs"
655664
runs-on: ubuntu-latest
656665
needs: [Setup, BuildDocs]
666+
# Always deploy docs (as requested)
657667
if: ${{ !(github.event.pull_request.head.repo.fork) }}
658668
steps:
659669
- name: Download a single artifact

0 commit comments

Comments
 (0)