Preview - CI #219
This file contains 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: Preview - CI | |
on: | |
workflow_dispatch: | |
schedule: | |
# 4:19 AM UTC every day. A random time to avoid peak times of GitHub Actions. | |
- cron: '19 4 * * *' | |
env: | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true | |
DOTNET_CLI_TELEMETRY_OPTOUT: true | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
name: Build, Test, Deploy | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Check if should publish | |
id: check-publish | |
shell: pwsh | |
run: | | |
$hasCommitFromLastDay = ![string]::IsNullOrEmpty((git log --oneline --since '24 hours ago')) | |
Write-Output "Commits found in the last 24 hours: $hasCommitFromLastDay." | |
$shouldPublish = ($hasCommitFromLastDay -and '${{ github.event_name }}' -eq 'schedule') -or ('${{ github.event_name }}' -eq 'workflow_dispatch') | |
"should-publish=$($shouldPublish ? 'true' : 'false')" >> $Env:GITHUB_OUTPUT | |
- uses: actions/setup-node@v4 | |
if: steps.check-publish.outputs.should-publish == 'true' | |
with: | |
node-version: "15" | |
- uses: actions/setup-dotnet@v4 | |
if: steps.check-publish.outputs.should-publish == 'true' | |
with: | |
dotnet-version: | | |
8.0.x | |
9.0.x | |
- name: Set build number | |
if: steps.check-publish.outputs.should-publish == 'true' | |
run: echo "BuildNumber=$(( $GITHUB_RUN_NUMBER ))" >> $GITHUB_ENV | |
- name: Build | |
if: steps.check-publish.outputs.should-publish == 'true' | |
# See pr_ci.yml for the reason why we disable NuGet audit warnings. | |
run: | | |
dotnet build -c Release -warnaserror /p:TreatWarningsAsErrors=true /p:RunAnalyzers=true /p:NuGetAudit=false | |
- name: Unit Tests | |
if: steps.check-publish.outputs.should-publish == 'true' | |
run: | | |
dotnet test -c Release --no-build ./tests/CrestApps.OrchardCore.Tests/CrestApps.OrchardCore.Tests.csproj | |
- name: Deploy preview NuGet packages | |
if: steps.check-publish.outputs.should-publish == 'true' | |
run: | | |
dotnet pack -c Release --no-build | |
dotnet nuget push './src/**/*.nupkg' -t 600 -k ${{secrets.CLOUDSMITH_API_KEY}} -n -s https://nuget.cloudsmith.io/crestapps/crestapps-orchardcore/v3/index.json --skip-duplicate |