# Gitea Actions workflow: .NET build with ephemeral VMware VM # Copy this file to: .gitea/workflows/build.yml in your repository. # # This workflow triggers on push to main/develop and on pull requests. # It routes the job to the act_runner with label "windows-build", # which creates an isolated VM per build. name: Build (.NET / MSBuild) on: push: branches: - main - develop - 'release/**' pull_request: branches: - main - develop jobs: build: # Must match the runner label defined in runner/config.yaml runs-on: windows-build # Job-level timeout (should be less than the runner's timeout setting) timeout-minutes: 90 env: # Override these per-repository or in Gitea's repository secrets # GITEA_CI_TEMPLATE_PATH is injected by runner/config.yaml global envs # GITEA_CI_CLONE_BASE_DIR is injected by runner/config.yaml global envs # Gitea Credential Manager target (set in runner/config.yaml) # The VM IP is auto-detected via vmrun getGuestIPAddress — no BUILD_VM_IP needed. GUEST_CRED_TARGET: "BuildVMGuest" steps: # Step 1: Check out the repository on the RUNNER HOST # (This gives the runner access to the scripts/ directory) - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 1 # Step 2: Invoke the orchestrator script # This script handles the entire VM lifecycle: # clone → start → wait ready → build → collect artifacts → destroy - name: Build in ephemeral VM shell: powershell run: | $ErrorActionPreference = 'Stop' # CI scripts are at a fixed location on the runner host. # Do NOT use $env:GITHUB_WORKSPACE — the CI system is in a separate repo. $ciScriptsDir = 'N:\Code\Workspace\Local-CI-CD-System\scripts' & "$ciScriptsDir\Invoke-CIJob.ps1" ` -JobId "${{ github.run_id }}-${{ github.run_attempt }}" ` -RepoUrl "ssh://gitea-ci/${{ github.repository }}.git" ` -Branch "${{ github.ref_name }}" ` -Commit "${{ github.sha }}" ` -Submodules ` -BuildCommand 'python build_plugin.py --final --dist-dir dist' ` -GuestArtifactSource 'dist' ` -GuestCredentialTarget "$env:GUEST_CRED_TARGET" if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } # Step 3: Upload artifacts to Gitea # Artifacts were collected to F:\CI\Artifacts\{JobId}\ by Invoke-CIJob.ps1 - name: Upload build artifacts if: success() uses: actions/upload-artifact@v4 with: name: build-${{ github.sha }} path: F:\CI\Artifacts\${{ github.run_id }}-${{ github.run_attempt }}\ retention-days: 14 if-no-files-found: error # Step 4: Upload artifacts even on failure (for diagnostics) - name: Upload diagnostic logs on failure if: failure() uses: actions/upload-artifact@v4 with: name: build-logs-${{ github.sha }} path: F:\CI\Artifacts\${{ github.run_id }}-${{ github.run_attempt }}\*.log retention-days: 3 if-no-files-found: ignore --- # PARALLEL BUILD VARIANT (using matrix strategy) # Uncomment and adapt if you need to build multiple configurations in parallel. # # jobs: # build: # runs-on: windows-build # strategy: # matrix: # include: # - config: Release # vm_ip: "192.168.11.101" # - config: Debug # vm_ip: "192.168.11.102" # fail-fast: false # # steps: # - uses: actions/checkout@v4 # - name: Build (${{ matrix.config }}) # shell: pwsh # run: | # & scripts\Invoke-CIJob.ps1 ` # -JobId "${{ github.run_id }}-${{ matrix.config }}" ` # -RepoUrl "${{ github.server_url }}/${{ github.repository }}.git" ` # -Branch "${{ github.ref_name }}" ` # -Configuration "${{ matrix.config }}" ` # -VMIPAddress "${{ matrix.vm_ip }}" --- # CROSS-PLATFORM MATRIX BUILD (Windows + Linux VMs) # Runs the same build on both Windows and Linux ephemeral VMs in parallel. # Requires: # - runner/config.yaml labels include "windows-build:host" and "linux-build:host" # - Linux template provisioned: F:\CI\Templates\LinuxBuild2404\LinuxBuild2404.vmx # - SSH key at F:\CI\keys\ci_linux (ed25519, no passphrase), user ci_build # # jobs: # build: # strategy: # matrix: # target: [windows, linux] # fail-fast: false # # runs-on: ${{ matrix.target }}-build # # steps: # - uses: actions/checkout@v4 # # - name: Build on ${{ matrix.target }} # shell: pwsh # run: | # $ErrorActionPreference = 'Stop' # $ciScriptsDir = Join-Path $env:GITHUB_WORKSPACE 'scripts' # # $templatePath = if ('${{ matrix.target }}' -eq 'linux') { # $env:GITEA_CI_LINUX_TEMPLATE_PATH # F:\CI\Templates\LinuxBuild2404\LinuxBuild2404.vmx # } else { # $env:GITEA_CI_TEMPLATE_PATH # F:\CI\Templates\WinBuild2025\WinBuild2025.vmx # } # # & "$ciScriptsDir\Invoke-CIJob.ps1" ` # -JobId "${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.target }}" ` # -RepoUrl "${{ github.server_url }}/${{ github.repository }}.git" ` # -Branch "${{ github.ref_name }}" ` # -Commit "${{ github.sha }}" ` # -TemplatePath $templatePath ` # -BuildCommand 'make all' # # - name: Upload artifacts (${{ matrix.target }}) # if: success() # uses: actions/upload-artifact@v4 # with: # name: build-${{ matrix.target }}-${{ github.sha }} # path: F:\CI\Artifacts\${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.target }}\ # retention-days: 14 # if-no-files-found: error