P3 done: workflow-example.yml usa composite action (generalizzazione per altri repo)

Riscritta gitea/workflow-example.yml per usare la composite action
Simone/local-ci-system/.gitea/actions/local-ci-build@main invece della
chiamata diretta a Invoke-CIJob.ps1.

Commenti inline guidano la personalizzazione per ogni repo:
- build-command e artifact-source (unici campi obbligatori da adattare)
- submodules, repo-url, use-git-clone (opzionali)
- extra-guest-env-json per secret injection (chiavi di firma, GPG)
- artifact-name personalizzato (e.g. con ref_name per tag build)

Aggiunge workflow_dispatch per trigger manuale.
Rimossa logica di orchestrazione inline: zero duplicazione tra repo.
TODO.md: Gitea Workflow Integration chiuso (5/5).
This commit is contained in:
Simone
2026-05-11 22:38:54 +02:00
parent 7d12dedddd
commit 6511d47a9a
2 changed files with 40 additions and 57 deletions
+34 -54
View File
@@ -1,11 +1,20 @@
# Gitea Actions workflow: .NET build with ephemeral VMware VM
# Gitea Actions workflow — generic build template using the composite action.
# 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.
# Adapt the two fields below to your project:
# build-command : the command to run inside the ephemeral VM
# artifact-source : the directory inside the VM where outputs are placed
#
# Runner label selects the guest OS automatically:
# windows-build -> WinBuild2025 (WinRM/HTTPS transport)
# linux-build -> LinuxBuild2404 (SSH transport)
#
# The composite action (Simone/local-ci-system/.gitea/actions/local-ci-build)
# handles the full VM lifecycle: clone template -> start -> build ->
# collect artifacts -> upload to Gitea -> destroy VM.
# No orchestration logic needed in each repo's workflow.
name: Build (.NET / MSBuild)
name: Build (Local CI)
on:
push:
@@ -17,67 +26,38 @@ on:
branches:
- main
- develop
workflow_dispatch:
jobs:
build:
# Must match the runner label defined in runner/config.yaml
# Change to linux-build for Ubuntu 24.04 guest
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
# ── Invoke the full VM lifecycle via composite action ───────────────────
- uses: Simone/local-ci-system/.gitea/actions/local-ci-build@main
with:
fetch-depth: 1
# --- adapt these two per-repository -----------------------------------
build-command: 'python build.py --dist-dir dist' # command run in VM
artifact-source: 'dist' # output dir in VM
# ----------------------------------------------------------------------
# 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'
# Uncomment to clone repo with submodules inside the VM:
# submodules: 'true'
# 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'
# Uncomment to clone via SSH alias instead of HTTPS (faster for large repos):
# repo-url: 'ssh://gitea-ci/${{ github.repository }}.git'
# use-git-clone: 'true'
& "$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"
# Uncomment to inject secrets as env vars in the VM (never logged):
# extra-guest-env-json: >-
# {"SIGN_PASS":"${{ secrets.SIGN_PASS }}",
# "GPG_KEY_ID":"${{ secrets.GPG_KEY_ID }}"}
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
# Artifact name defaults to build-{run_id}-{sha}.
# Uncomment to use a custom name (e.g. include ref_name for tag builds):
# artifact-name: 'myproject-${{ github.ref_name }}'
if-no-files-found: error
# Step 4: Upload artifacts even on failure (for diagnostics)