f5f0948552
Agent packaging was manual: nothing put the installer where the backend looks, so /api/enrollment/agent-package 404'd until someone seeded /data/agent by hand. It is now automatic. Automatic agent delivery: - CI's Windows job packages the agent and uploads it as an artifact; the Linux image job stages it into the backend image at /opt/executer/agent before docker build, so a stock deployment serves installs immediately - Resolution order: AGENT_PACKAGE_PATH, then the baked-in image copy, then /data/agent for local builds and air-gapped installs - A warning is emitted (not a failure) if no package was staged - Settings shows the live source, size, version and SHA-256 S3 configurable and testable from the WebUI: - Settings are persisted in a new AppSettings table and override the S3_* environment defaults; the secret key is encrypted at rest with Data Protection and never returned to the browser (blank on save keeps it) - Test connection performs a real round-trip - bucket, write, read-back, presigned download, delete - reporting each step separately so read-only credentials or an endpoint unreachable from agents are distinguishable - Only a fully passing test records lastTestUtc Optional S3 offload of the installer: - Requires a passing test; upload is content-addressed by hash so re-uploading an unchanged build is skipped - When enabled, /api/enrollment/agent-package 302s to a presigned URL, keeping large downloads off the control plane, and falls back to local streaming if presigning fails rather than breaking installs S3PresignService now resolves settings per call, so UI changes take effect without restarting the backend. Migrations added for all three providers. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
193 lines
7.2 KiB
YAML
193 lines
7.2 KiB
YAML
name: CI
|
|
|
|
on:
|
|
pull_request:
|
|
branches: [main]
|
|
push:
|
|
branches: [dev, main]
|
|
|
|
jobs:
|
|
build-test:
|
|
# Windows is required to build/test the agent (CIM, ConPTY, DPAPI, service).
|
|
# Label must match a registered runner: windows-host.
|
|
runs-on: windows-host
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup .NET 10
|
|
uses: actions/setup-dotnet@v4
|
|
with:
|
|
dotnet-version: '10.0.x'
|
|
|
|
- name: Setup Node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
|
|
- name: Compute unified version
|
|
id: ver
|
|
shell: pwsh
|
|
run: |
|
|
$v = & ./scripts/Get-UnifiedVersion.ps1
|
|
"version=$v" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
|
|
Write-Host "Unified version: $v"
|
|
|
|
- name: Restore
|
|
run: dotnet restore ExecuteR.slnx
|
|
|
|
- name: Build
|
|
run: dotnet build ExecuteR.slnx -c Release --no-restore "-p:UnifiedVersion=${{ steps.ver.outputs.version }}"
|
|
|
|
- name: Unit tests
|
|
run: |
|
|
dotnet test tests/Shared.Tests -c Release --no-build --nologo
|
|
dotnet test tests/Agent.Tests -c Release --no-build --nologo
|
|
dotnet test tests/Backend.Tests -c Release --no-build --nologo
|
|
|
|
- name: Integration tests
|
|
run: dotnet test tests/Integration.Tests -c Release --no-build --nologo
|
|
|
|
- name: WebUI install
|
|
run: npm ci
|
|
working-directory: src/WebUI
|
|
|
|
- name: WebUI check
|
|
run: npm run check
|
|
working-directory: src/WebUI
|
|
|
|
- name: WebUI build
|
|
env:
|
|
PUBLIC_BUILD_VERSION: ${{ steps.ver.outputs.version }}
|
|
run: npm run build
|
|
working-directory: src/WebUI
|
|
|
|
# Package the agent here (only Windows can build it) so the Linux image
|
|
# job can bake it into the backend image — no manual seeding at deploy.
|
|
- name: Package agent
|
|
if: ${{ github.event_name == 'push' }}
|
|
shell: pwsh
|
|
run: |
|
|
./scripts/Package-Agent.ps1 -Version ${{ steps.ver.outputs.version }}
|
|
$stage = 'artifacts/agent-package'
|
|
New-Item -ItemType Directory -Force $stage | Out-Null
|
|
$msi = "artifacts/Agent-${{ steps.ver.outputs.version }}.msi"
|
|
$zip = "artifacts/Agent-${{ steps.ver.outputs.version }}-win-x64.zip"
|
|
if (Test-Path $msi) { Copy-Item $msi "$stage/Agent.msi" }
|
|
if (Test-Path $zip) { Copy-Item $zip "$stage/Agent.zip" }
|
|
'${{ steps.ver.outputs.version }}' | Set-Content "$stage/VERSION" -NoNewline
|
|
Get-ChildItem $stage | Select-Object Name, Length
|
|
|
|
- name: Upload agent package
|
|
if: ${{ github.event_name == 'push' }}
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: agent-package
|
|
path: artifacts/agent-package/
|
|
retention-days: 7
|
|
|
|
images:
|
|
# Build the backend + webui images and publish them to the Gitea container
|
|
# registry. Image names match what docker-compose.yml pulls:
|
|
# <gitea-host>/<owner>/executer-backend:<tag>
|
|
# <gitea-host>/<owner>/executer-webui:<tag>
|
|
needs: build-test
|
|
if: ${{ github.event_name == 'push' }}
|
|
# Needs Docker; label must match a registered Linux runner.
|
|
runs-on: ubuntu-host
|
|
env:
|
|
# Gitea's built-in container registry lives on the Gitea host itself and
|
|
# needs no configuration: Actions injects GITEA_TOKEN per run and it is
|
|
# accepted as the registry password for the triggering actor.
|
|
# The REGISTRY_* secrets are only an override for an EXTERNAL registry.
|
|
REGISTRY_HOST: ${{ secrets.REGISTRY_HOST }}
|
|
REGISTRY_USER: ${{ secrets.REGISTRY_USERNAME }}
|
|
REGISTRY_PASS: ${{ secrets.REGISTRY_PASSWORD }}
|
|
SERVER_URL: ${{ github.server_url }}
|
|
ACTOR: ${{ github.actor }}
|
|
BUILTIN_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
OWNER: ${{ github.repository_owner }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Resolve version and registry target
|
|
id: ver
|
|
shell: bash
|
|
run: |
|
|
set -e
|
|
echo "version=$(date -u +%Y.%m.%d.%H%M)" >> "$GITHUB_OUTPUT"
|
|
|
|
# Default to Gitea's own registry on this instance; fall back to the
|
|
# REGISTRY_* secrets only when an external registry is configured.
|
|
if [ -n "$REGISTRY_HOST" ]; then
|
|
HOST="$REGISTRY_HOST"; USER="$REGISTRY_USER"; PASS="$REGISTRY_PASS"
|
|
echo "Using external registry $HOST"
|
|
else
|
|
HOST="$(echo "$SERVER_URL" | sed -E 's#^https?://##; s#/$##')"
|
|
USER="$ACTOR"; PASS="$BUILTIN_TOKEN"
|
|
echo "Using the built-in Gitea registry at $HOST"
|
|
fi
|
|
|
|
# Gitea package paths are lowercase.
|
|
OWNER_LC="$(echo "$OWNER" | tr '[:upper:]' '[:lower:]')"
|
|
|
|
{
|
|
echo "host=$HOST"
|
|
echo "user=$USER"
|
|
echo "prefix=${HOST}/${OWNER_LC}/executer"
|
|
} >> "$GITHUB_OUTPUT"
|
|
echo "::add-mask::$PASS"
|
|
echo "REGISTRY_LOGIN_PASSWORD=$PASS" >> "$GITHUB_ENV"
|
|
|
|
- name: Registry login
|
|
run: echo "$REGISTRY_LOGIN_PASSWORD" | docker login "${{ steps.ver.outputs.host }}" -u "${{ steps.ver.outputs.user }}" --password-stdin
|
|
|
|
# Bake the Windows-built agent into the backend image so the URL install
|
|
# flow serves it with no manual seeding.
|
|
- name: Download agent package
|
|
uses: actions/download-artifact@v3
|
|
continue-on-error: true
|
|
with:
|
|
name: agent-package
|
|
path: src/Infra/backend/agent-package
|
|
|
|
- name: Confirm agent package staged
|
|
run: |
|
|
if ls src/Infra/backend/agent-package/Agent.* >/dev/null 2>&1; then
|
|
echo "Agent package will be baked into the backend image:"
|
|
ls -la src/Infra/backend/agent-package/
|
|
else
|
|
echo "::warning::No agent package staged - the backend image will ship without an installer and /api/enrollment/agent-package will 404 until one is mounted or offloaded to S3."
|
|
fi
|
|
|
|
- name: Build images
|
|
env:
|
|
VERSION: ${{ steps.ver.outputs.version }}
|
|
PREFIX: ${{ steps.ver.outputs.prefix }}
|
|
run: |
|
|
set -e
|
|
docker build -f src/Infra/backend/Dockerfile --build-arg UNIFIED_VERSION="$VERSION" -t "${PREFIX}-backend:$VERSION" .
|
|
docker build -f src/Infra/webui/Dockerfile --build-arg UNIFIED_VERSION="$VERSION" -t "${PREFIX}-webui:$VERSION" .
|
|
|
|
- name: Tag and push
|
|
env:
|
|
VERSION: ${{ steps.ver.outputs.version }}
|
|
PREFIX: ${{ steps.ver.outputs.prefix }}
|
|
REF_NAME: ${{ github.ref_name }}
|
|
run: |
|
|
set -e
|
|
for svc in backend webui; do
|
|
docker push "${PREFIX}-${svc}:$VERSION"
|
|
if [ "$REF_NAME" = "main" ]; then
|
|
docker tag "${PREFIX}-${svc}:$VERSION" "${PREFIX}-${svc}:latest"
|
|
docker push "${PREFIX}-${svc}:latest"
|
|
else
|
|
docker tag "${PREFIX}-${svc}:$VERSION" "${PREFIX}-${svc}:dev"
|
|
docker tag "${PREFIX}-${svc}:$VERSION" "${PREFIX}-${svc}:${VERSION}-dev"
|
|
docker push "${PREFIX}-${svc}:dev"
|
|
docker push "${PREFIX}-${svc}:${VERSION}-dev"
|
|
fi
|
|
done
|
|
echo "Published ${PREFIX}-backend and ${PREFIX}-webui"
|