From fe6ec3a9b4052f124900065370c67f57ed9925ea Mon Sep 17 00:00:00 2001 From: Alberto Balbo Date: Fri, 23 Oct 2026 10:15:28 +0200 Subject: [PATCH] ci: probe registry sign-in Co-Authored-By: Claude Opus 5.5 --- .gitea/workflows/probe.yml | 141 ++++++++----------------------------- 1 file changed, 30 insertions(+), 111 deletions(-) diff --git a/.gitea/workflows/probe.yml b/.gitea/workflows/probe.yml index df50102e..ffaf0be6 100644 --- a/.gitea/workflows/probe.yml +++ b/.gitea/workflows/probe.yml @@ -1,4 +1,4 @@ -# Temporary probe of the Gitea runner (deleted after use): tools, contexts, services, registry, cross-publishing. +# Temporary probe of the Gitea runner (deleted after use): registry sign-in with the automatic token, archive download. name: Probe on: @@ -6,128 +6,47 @@ on: branches: [ci-probe] workflow_dispatch: -permissions: - contents: read - packages: write - jobs: - default-image: + registry: runs-on: ubuntu-latest + permissions: + contents: read + packages: write steps: - - name: Environment + - name: Tools of the runner image run: | - head -3 /etc/os-release || true - for t in bash node git docker ruby curl jq python3 pwsh 7z zip unzip openssl dotnet; do printf '%-8s %s\n' "$t" "$(command -v $t || echo -)"; done - nproc; free -m || true; df -h / /tmp | cat - echo "server_url=${{ github.server_url }} api_url=${{ github.api_url }} repo=${{ github.repository }} owner=${{ github.repository_owner }} actor=${{ github.actor }}" - echo "ref=${{ github.ref }} ref_name=${{ github.ref_name }} sha=${{ github.sha }} run=${{ github.run_number }} id=${{ github.run_id }} event=${{ github.event_name }}" - echo "GITEA_ACTIONS=$GITEA_ACTIONS GITHUB_ACTIONS=$GITHUB_ACTIONS RUNNER_OS=$RUNNER_OS RUNNER_TEMP=$RUNNER_TEMP" - echo "GITHUB_STEP_SUMMARY=$GITHUB_STEP_SUMMARY GITHUB_OUTPUT=$GITHUB_OUTPUT GITHUB_ENV=$GITHUB_ENV" - echo "vars.PROBE='${{ vars.PROBE }}' secrets.RELEASES_TOKEN set: ${{ secrets.RELEASES_TOKEN != '' }}" - ls -l /var/run/docker.sock || true - docker version 2>&1 | head -20 || true - - name: Workflow commands - run: | - echo "::notice title=Probe::a notice" - echo "::warning title=Probe::a warning" - echo "::group::a group"; echo inside; echo "::endgroup::" - echo "## Summary from the probe" >> "$GITHUB_STEP_SUMMARY" - - sdk: - runs-on: ubuntu-latest - container: - image: mcr.microsoft.com/dotnet/sdk:10.0 - services: - postgres: - image: postgres:17 - env: - POSTGRES_USER: titano - POSTGRES_PASSWORD: titano-ci - POSTGRES_DB: titano_test - defaults: - run: - shell: bash - env: - DOTNET_NOLOGO: "1" - DOTNET_CLI_TELEMETRY_OPTOUT: "1" - steps: - - name: Context - run: | - echo "job.services.postgres.id='${{ job.services.postgres.id }}' network='${{ job.services.postgres.network }}'" - echo "job.container.id='${{ job.container.id }}' network='${{ job.container.network }}'" - echo "hostname=$(hostname) workspace=$GITHUB_WORKSPACE pwd=$(pwd) user=$(id)" - getent hosts postgres || echo "postgres does not resolve" - ls -l /var/run/docker.sock || true - for t in node git docker ruby curl jq python3 openssl 7z zip unzip pwsh tar gzip; do printf '%-8s %s\n' "$t" "$(command -v $t || echo -)"; done - nproc; free -m; df -h / /tmp "$GITHUB_WORKSPACE" | cat - dotnet --list-sdks - head -3 /etc/os-release - - name: Checkout with git (no node) + docker buildx version || echo "no buildx" + docker info --format 'buildkit default: {{.ClientInfo.DefaultContext}}' 2>/dev/null || true + - name: Packages API and registry sign-in with the automatic token env: TOKEN: ${{ github.token }} run: | - git config --global --add safe.directory "$PWD" - git init -q . - git remote add origin "${{ github.server_url }}/${{ github.repository }}.git" - auth=$(printf 'x-access-token:%s' "$TOKEN" | base64 -w0) - time git -c http.extraheader="Authorization: basic $auth" fetch -q --depth=1 origin "${{ github.sha }}" - git checkout -q FETCH_HEAD - git log --oneline -1 - - name: PostgreSQL service reachable - run: | - for i in $(seq 1 90); do - if (echo > /dev/tcp/postgres/5432) 2>/dev/null; then echo "postgres:5432 open after ${i}s"; break; fi - sleep 1 + for path in "packages/BalboSoft" "packages/Alby96" "repos/BalboSoft/Chronos" "user"; do + code=$(curl -s -o /tmp/r.txt -w '%{http_code}' -H "Authorization: token $TOKEN" "${{ github.server_url }}/api/v1/$path") + echo "GET /api/v1/$path -> $code $(head -c 160 /tmp/r.txt)" done - - name: Build Tools, cross-publish App and Setup (win-x64) - run: | - set -o pipefail - time dotnet build src/Titano.Tools/Titano.Tools.csproj -c Release -nologo -clp:NoSummary 2>&1 | tail -5 - common="-c Release -r win-x64 --self-contained -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:DebugType=none -nologo" - time dotnet publish src/Titano.App/Titano.App.csproj $common -p:PublishReadyToRun=true -o out/app 2>&1 | tail -15 - time dotnet publish src/Titano.Setup/Titano.Setup.csproj $common -p:PublishReadyToRun=true -o out/setup 2>&1 | tail -15 - time dotnet publish src/Titano.Server/Titano.Server.csproj $common -o out/server 2>&1 | tail -5 - ls -la out/app out/setup out/server - - name: PE resources of the cross-published programs - run: | - mkdir -p /tmp/pecheck && cp .gitea/probe/pe.cs /tmp/pecheck/pe.cs - cd /tmp/pecheck && dotnet run pe.cs -- "$GITHUB_WORKSPACE/out/app/Titano.exe" "$GITHUB_WORKSPACE/out/setup/Titano.Setup.exe" "$GITHUB_WORKSPACE/out/server/Titano.Server.exe" - - name: Pack an installer on Linux - run: | - dotnet src/Titano.Tools/bin/Release/net10.0/Titano.Tools.dll pack-installer --setup out/setup/Titano.Setup.exe --product Titano \ - --component "Titano=out/app" --version 0.0.1 --out out/Titano-Setup-0.0.1.exe - ls -la out/*.exe - cd /tmp/pecheck && dotnet run pe.cs -- "$GITHUB_WORKSPACE/out/Titano-Setup-0.0.1.exe" - - docker-cli: - runs-on: ubuntu-latest - container: - image: docker:27-cli - steps: - - name: Host daemon through the socket - run: | - docker version - docker info --format 'name={{.Name}} os={{.OperatingSystem}} arch={{.Architecture}} cpus={{.NCPU}} mem={{.MemTotal}} root={{.DockerRootDir}}' - docker info --format '{{json .RegistryConfig.IndexConfigs}}' - docker buildx version || true - docker buildx ls || true - docker image ls --format '{{.Repository}}:{{.Tag}} {{.Size}}' | head -30 - - name: Registry login (client) and pull (daemon) - env: - TOKEN: ${{ github.token }} - run: | - for host in gitea.encke-hake.ts.net 192.168.30.23:3000; do - if echo "$TOKEN" | docker login "$host" -u "${{ github.actor }}" --password-stdin; then echo "login $host OK"; else echo "login $host FAILED"; fi - docker pull "$host/balbosoft/chronos-probe-missing:latest" 2>&1 | tail -2 || true + for user in "${{ github.actor }}" gitea-actions x-access-token BalboSoft; do + if printf '%s' "$TOKEN" | timeout 60 docker login gitea.encke-hake.ts.net -u "$user" --password-stdin > /tmp/login.txt 2>&1; then + echo "login as $user: OK"; docker logout gitea.encke-hake.ts.net > /dev/null 2>&1 || true + else + echo "login as $user: FAILED $(tail -1 /tmp/login.txt)" + fi done + code=$(curl -s -o /tmp/t.txt -w '%{http_code}' -u "x:$TOKEN" "https://gitea.encke-hake.ts.net/v2/token?service=container_registry&scope=repository:balbosoft/chronos-probe:push,pull") + echo "token endpoint -> $code $(head -c 200 /tmp/t.txt)" - ruby: + archive: runs-on: ubuntu-latest container: image: ruby:3.3-alpine steps: - - name: Ruby + - name: Sources as an archive, YAML check + env: + TOKEN: ${{ github.token }} run: | - ruby -v - ruby -ryaml -e 'puts YAML.safe_load("a: 1").inspect' - command -v git || echo "no git" + wget -q --header "Authorization: token $TOKEN" -O /tmp/sources.tar.gz \ + "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/archive/${{ github.sha }}.tar.gz" + mkdir -p /tmp/sources && tar -xzf /tmp/sources.tar.gz -C /tmp/sources + ls /tmp/sources + cd /tmp/sources/*/ + ruby .github/scripts/check-yaml.rb .gitea/workflows/*.yml deploy/docker/docker-compose.yml deploy/releases-repo/.github/ISSUE_TEMPLATE/*.yml