nightly #328
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: nightly | |
| on: | |
| workflow_dispatch : | |
| branches : | |
| - dev | |
| schedule: | |
| - cron: '0 0 * * *' | |
| jobs: | |
| nightly: | |
| runs-on: [self-hosted, Windows, X64, AX, APP] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: '0' | |
| - name: Get Branch Name | |
| run: | | |
| if ($env:GITHUB_REF -like "refs/pull/*") { | |
| $BRANCH_NAME = "${{ github.event.pull_request.head.ref }}" | |
| } else { | |
| $BRANCH_NAME = $env:GITHUB_REF -replace 'refs/heads/', '' | |
| } | |
| Write-Host "Triggered on branch: $BRANCH_NAME" | |
| "BRANCH_NAME=$BRANCH_NAME" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 | |
| shell: pwsh | |
| - name: Get Short Commit SHA | |
| run: | | |
| $currentSHA = git rev-parse --short HEAD | |
| "CURRENT_SHA=$currentSHA" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 | |
| shell: pwsh | |
| - name: Setup | |
| run: | | |
| "TEST_EXIT_CODE=123" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 | |
| "PACK_EXIT_CODE=123" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 | |
| shell: pwsh | |
| - name: Set default value for SKIP_STEPS | |
| run: | | |
| "SKIP_STEPS=false" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 | |
| shell: pwsh | |
| - name: Fetch Stored Commit SHA from Repository Variable | |
| if: github.ref == 'refs/heads/dev' && github.event_name != 'workflow_dispatch' | |
| run: | | |
| $storedSHA = gh variable get LAST_DEV_COMMIT_SHA --json value | ConvertFrom-Json | Select-Object -ExpandProperty value | |
| "STORED_SHA=$storedSHA" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 | |
| env: | |
| GH_TOKEN : ${{ secrets.GH_TOKEN }} | |
| shell: pwsh | |
| - name: Fetch Stored APP_RUN_RESULT from Repository Variable | |
| if: github.ref == 'refs/heads/dev' && github.event_name != 'workflow_dispatch' | |
| run: | | |
| $appRunResult = gh variable get APP_RUN_RESULT --json value | ConvertFrom-Json | Select-Object -ExpandProperty value | |
| "APP_RUN_RESULT=$appRunResult" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 | |
| env: | |
| GH_TOKEN : ${{ secrets.GH_TOKEN }} | |
| shell: pwsh | |
| - name: Compare Commit SHAs and previous result | |
| if: github.ref == 'refs/heads/dev' && github.event_name != 'workflow_dispatch' | |
| run: | | |
| if ($env:CURRENT_SHA -eq $env:STORED_SHA -and $env:APP_RUN_RESULT -eq "1") { | |
| echo "SHA Match: Skipping Steps" | |
| "SKIP_STEPS=true" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 | |
| } | |
| shell: pwsh | |
| - name: Reset APP_RUN_RESULT in Repository Variable | |
| if: env.SKIP_STEPS == 'false' | |
| run: | | |
| gh variable set APP_RUN_RESULT --body "0" | |
| env: | |
| GH_TOKEN : ${{ secrets.GH_TOKEN }} | |
| shell: pwsh | |
| - name: "Build script" | |
| if: env.SKIP_STEPS == 'false' | |
| run: dotnet build cake/Build.csproj | |
| shell: pwsh | |
| - name: "Run build script" | |
| continue-on-error: true | |
| if: env.SKIP_STEPS == 'false' | |
| env: | |
| GH_TOKEN : ${{ secrets.GH_TOKEN }} | |
| GH_USER : ${{ secrets.GH_USER }} | |
| run: | | |
| dotnet run --project cake/Build.csproj --apps-run | |
| "TEST_EXIT_CODE=$LASTEXITCODE" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 | |
| shell: pwsh | |
| - name: Store Commit SHA in Repository Variable | |
| if: env.SKIP_STEPS == 'false' | |
| run: | | |
| gh variable set LAST_DEV_COMMIT_SHA --body "$env:CURRENT_SHA" | |
| env: | |
| GH_TOKEN : ${{ secrets.GH_TOKEN }} | |
| shell: pwsh | |
| - name: Set APP_RUN_RESULT | |
| if: env.SKIP_STEPS == 'false' | |
| run: | | |
| if ($env:TEST_EXIT_CODE -eq "0") { | |
| echo "Tests passed. Setting APP_RUN_RESULT=1" | |
| gh variable set APP_RUN_RESULT --body "1" | |
| } else { | |
| echo "Tests failed. APP_RUN_RESULT not set." | |
| } | |
| env: | |
| GH_TOKEN : ${{ secrets.GH_TOKEN }} | |
| shell: pwsh | |
| - name: Display workflow details in Summary | |
| run: | | |
| if($env:TEST_EXIT_CODE -eq "123") | |
| { | |
| $TEST_RESULT = "SKIPPED" | |
| } | |
| elseif($env:TEST_EXIT_CODE -eq "0") | |
| { | |
| $TEST_RESULT = "PASSED" | |
| } | |
| else | |
| { | |
| $TEST_RESULT = "FAILED" | |
| } | |
| "### Runner name: $env:RUNNER_NAME ::: Branch name: $env:BRANCH_NAME ::: Commit SHA: $env:CURRENT_SHA ::: Test result: $TEST_RESULT" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append -Encoding utf8 | |
| shell: pwsh | |
| - name: Evaluate final result | |
| if: env.SKIP_STEPS == 'false' | |
| run: | | |
| if($env:TEST_EXIT_CODE -eq "123") | |
| { | |
| echo "Tests skipped." | |
| } | |
| elseif($env:TEST_EXIT_CODE -eq "0") | |
| { | |
| echo "Tests passed." | |
| } | |
| else | |
| { | |
| echo "Tests failed." | |
| Exit 1 | |
| } | |
| shell: pwsh |