Skip to content

Preview - CI

Preview - CI #2372

Workflow file for this run

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:
# To enable this workflow on a fork, comment out:
if: github.repository == 'OrchardCMS/OrchardCore'
runs-on: ubuntu-24.04
name: Build, Test, Deploy
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
- 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@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
if: steps.check-publish.outputs.should-publish == 'true'
with:
node-version: "15"
- uses: ./.github/actions/setup-dotnet
if: steps.check-publish.outputs.should-publish == 'true'
- name: Set build number
if: steps.check-publish.outputs.should-publish == 'true'
run: echo "BuildNumber=$(( $GITHUB_RUN_NUMBER + 16368 ))" >> $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 /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 ./test/OrchardCore.Tests/OrchardCore.Tests.csproj
- name: Functional Tests
if: steps.check-publish.outputs.should-publish == 'true'
run: |
cd test/OrchardCore.Tests.Functional
npm install
npm run cms:test
npm run mvc:test
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
if: failure()
with:
name: Functional Test failure
path: |
test/OrchardCore.Tests.Functional/cms-tests/cypress/screenshots
src/OrchardCore.Cms.Web/App_Data_Tests/logs
- 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/orchardcore/preview/v3/index.json --skip-duplicate
- name: Set up Docker Buildx
if: steps.check-publish.outputs.should-publish == 'true'
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3
- name: Login to DockerHub
if: steps.check-publish.outputs.should-publish == 'true'
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Deploy preview Docker images
if: steps.check-publish.outputs.should-publish == 'true'
shell: pwsh
run: |
Get-ChildItem ./src/OrchardCore.Cms.Web/App_Data -Recurse | Remove-Item -Recurse -Confirm:$false
Get-ChildItem ./src/OrchardCore.Cms.Web/App_Data_Tests -Recurse | Remove-Item -Recurse -Confirm:$false
$output = [System.IO.Path]::GetFullPath("./.build/release")
dotnet publish -c Release --property:PublishDir=$output --no-build --framework net9.0
docker buildx build -f Dockerfile-CI --platform=linux/amd64 -t orchardproject/orchardcore-cms-linux:dev --push .
docker buildx build -f Dockerfile-CI --platform=windows/amd64 -t orchardproject/orchardcore-cms-windows:dev --push .