name: Immagine nightly # L'immagine del server di main come :nightly nel registro container di Gitea (ADR 0014). Mai una release. on: schedule: - cron: "37 2 * * *" workflow_dispatch: permissions: contents: read packages: write env: PUBLIC_URL: ${{ vars.PUBLIC_URL || 'https://gitea.encke-hake.ts.net' }} jobs: nightly: if: github.ref == 'refs/heads/main' runs-on: ubuntu-latest timeout-minutes: 60 steps: - name: Checkout 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" git -c http.extraheader="Authorization: basic $(printf 'x-access-token:%s' "$TOKEN" | base64 -w0)" fetch -q --depth=1 origin "${{ github.sha }}" git checkout -q FETCH_HEAD - name: Accesso al registro env: REGISTRY: ${{ vars.REGISTRY }} USER: ${{ vars.REGISTRY_USER || github.actor }} TOKEN: ${{ secrets.REGISTRY_TOKEN || github.token }} run: | registry="${REGISTRY:-$(printf '%s' "$PUBLIC_URL" | sed -E 's#^[a-z]+://##; s#/.*$##')}" owner="$(printf '%s' "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')" { echo "REGISTRY_HOST=$registry"; echo "IMAGE=$registry/$owner/rail-enterprise-server"; } >> "$GITHUB_ENV" if ! printf '%s' "$TOKEN" | docker login "$registry" -u "$USER" --password-stdin; then echo "::error title=Registro::Accesso a $registry rifiutato: serve il segreto REGISTRY_TOKEN." exit 1 fi - name: Build e push run: | docker build -f docker/Dockerfile --build-arg RE_VERSION="0.0.0-nightly.${{ github.run_number }}" -t "$IMAGE:nightly" . docker push "$IMAGE:nightly" - name: Pulizia if: always() run: | docker image rm "$IMAGE:nightly" 2> /dev/null || true docker logout "$REGISTRY_HOST" || true