140 lines
4.3 KiB
YAML
140 lines
4.3 KiB
YAML
# ─── Heimdall — Forgejo CI Pipeline ────────────────────────────
|
|
# Runner: Debian 12 (auto-scaler / LXC)
|
|
# Actions: mirror sur forgejo.tordais.cc (checkout, setup-dotnet, cache)
|
|
|
|
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main, develop]
|
|
paths-ignore:
|
|
- '**.md'
|
|
- '.opencode/**'
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
env:
|
|
DOTNET_VERSION: "10.0"
|
|
DOTNET_CLI_TELEMETRY_OPTOUT: 1
|
|
DOTNET_NOLOGO: 1
|
|
|
|
concurrency:
|
|
group: ci-${{ forgejo.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
build-and-test:
|
|
runs-on: debian-12
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:17-alpine
|
|
env:
|
|
POSTGRES_DB: heimdall_test
|
|
POSTGRES_USER: heimdall
|
|
POSTGRES_PASSWORD: heimdall
|
|
ports:
|
|
- 5432:5432
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: https://forgejo.tordais.cc/actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Setup .NET ${{ env.DOTNET_VERSION }}
|
|
uses: https://forgejo.tordais.cc/actions/setup-dotnet@v4
|
|
with:
|
|
dotnet-version: ${{ env.DOTNET_VERSION }}
|
|
|
|
- name: Cache NuGet packages
|
|
uses: https://forgejo.tordais.cc/actions/cache@v4
|
|
with:
|
|
path: ~/.nuget/packages
|
|
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/Directory.Build.props') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-nuget-
|
|
|
|
- name: Restore
|
|
run: dotnet restore
|
|
|
|
- name: Build
|
|
run: dotnet build --no-restore -c Release
|
|
|
|
- name: Test
|
|
run: dotnet test --no-build -c Release
|
|
env:
|
|
DATABASE_URL: "Host=localhost;Port=5432;Database=heimdall_test;Username=heimdall;Password=heimdall"
|
|
|
|
docker-build:
|
|
needs: build-and-test
|
|
runs-on: debian-12
|
|
if: forgejo.ref == 'refs/heads/main'
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: https://forgejo.tordais.cc/actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Setup .NET ${{ env.DOTNET_VERSION }}
|
|
uses: https://forgejo.tordais.cc/actions/setup-dotnet@v4
|
|
with:
|
|
dotnet-version: ${{ env.DOTNET_VERSION }}
|
|
|
|
- name: Cache NuGet packages
|
|
uses: https://forgejo.tordais.cc/actions/cache@v4
|
|
with:
|
|
path: ~/.nuget/packages
|
|
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/Directory.Build.props') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-nuget-
|
|
|
|
- name: Restore & Build
|
|
run: |
|
|
dotnet restore
|
|
dotnet build --no-restore -c Release
|
|
|
|
- name: Install Docker CLI
|
|
run: |
|
|
apt-get -qq update
|
|
apt-get install -y -qq --no-install-recommends docker.io
|
|
|
|
- name: Build Central image
|
|
run: |
|
|
docker build -f docker/Dockerfile.central -t heimdall/central:latest .
|
|
|
|
- name: Build Agent image
|
|
run: |
|
|
docker build -f docker/Dockerfile.agent -t heimdall/agent:latest .
|
|
|
|
- name: Login to Docker Hub
|
|
if: secrets.DOCKER_USERNAME != '' && secrets.DOCKER_PASSWORD != ''
|
|
run: |
|
|
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
|
|
|
|
- name: Tag & Push Central image
|
|
if: secrets.DOCKER_USERNAME != '' && secrets.DOCKER_PASSWORD != ''
|
|
run: |
|
|
docker tag heimdall/central:latest \
|
|
${{ secrets.DOCKER_USERNAME }}/heimdall-central:${{ forgejo.sha }}
|
|
docker tag heimdall/central:latest \
|
|
${{ secrets.DOCKER_USERNAME }}/heimdall-central:latest
|
|
docker push ${{ secrets.DOCKER_USERNAME }}/heimdall-central:${{ forgejo.sha }}
|
|
docker push ${{ secrets.DOCKER_USERNAME }}/heimdall-central:latest
|
|
|
|
- name: Tag & Push Agent image
|
|
if: secrets.DOCKER_USERNAME != '' && secrets.DOCKER_PASSWORD != ''
|
|
run: |
|
|
docker tag heimdall/agent:latest \
|
|
${{ secrets.DOCKER_USERNAME }}/heimdall-agent:${{ forgejo.sha }}
|
|
docker tag heimdall/agent:latest \
|
|
${{ secrets.DOCKER_USERNAME }}/heimdall-agent:latest
|
|
docker push ${{ secrets.DOCKER_USERNAME }}/heimdall-agent:${{ forgejo.sha }}
|
|
docker push ${{ secrets.DOCKER_USERNAME }}/heimdall-agent:latest
|