fix workflow
build / check (push) Successful in 1m58s
build / build (push) Successful in 3m53s

This commit is contained in:
mrambossek
2026-08-26 13:02:33 +02:00
parent 79de2315f6
commit 2e49a8eb31
+93 -32
View File
@@ -1,36 +1,38 @@
name: Build fdroidserver-ipfs image # ci-images/fdroidserver-ipfs/.gitea/workflows/build.yaml
#
# Daily check, build ONLY when the upstream base or the Dockerfile changed.
# See the flutter-node variant for the full explanation - identical logic,
# one upstream base instead of two.
name: build
# Triggers:
# - push to main → immediate rebuild (any change in the repo)
# - weekly cron → picks up upstream :master refreshes in
# docker-executable-fdroidserver without a
# source change here
# - manual dispatch → on-demand
on: on:
schedule:
- cron: "0 4 * * *"
push: push:
branches: [main] branches: [main]
schedule:
# Sun 04:00 UTC.
- cron: "0 4 * * 0"
workflow_dispatch: workflow_dispatch:
inputs:
force:
description: "Build even if no upstream change was detected"
type: boolean
default: false
env:
IMAGE: ${{ vars.REGISTRY_HOST }}/ci-images/fdroidserver-ipfs
FDROIDSERVER_IMAGE: registry.gitlab.com/fdroid/docker-executable-fdroidserver:master
jobs: jobs:
build: check:
# Skip the job entirely (no runner provisioning) when the registry host
# isn't configured — shows as "skipped" in the UI rather than burning
# minutes on a build that can't be pushed. Secrets can't be referenced
# in job-level if:, so REGISTRY_TOKEN is still checked below.
if: vars.REGISTRY_HOST != ''
runs-on: ubuntu-docker runs-on: ubuntu-docker
permissions: outputs:
packages: write changed: ${{ steps.cmp.outputs.changed }}
hash: ${{ steps.hash.outputs.hash }}
base: ${{ steps.up.outputs.base }}
date: ${{ steps.date.outputs.date }}
steps: steps:
- name: Validate registry token - name: Validate registry token
run: | run: test -n "${{ secrets.REGISTRY_TOKEN }}" || { echo "REGISTRY_TOKEN missing"; exit 1; }
if [ -z "${{ secrets.REGISTRY_TOKEN }}" ]; then
echo "::error::Missing required config: secrets.REGISTRY_TOKEN"
exit 1
fi
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
@@ -38,15 +40,69 @@ jobs:
- name: Set up Buildx - name: Set up Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Log in to Gitea registry
uses: docker/login-action@v3
with:
registry: ${{ vars.REGISTRY_HOST }}
username: ${{ github.actor }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Resolve upstream digest
id: up
run: |
set -euo pipefail
b=$(docker buildx imagetools inspect "$FDROIDSERVER_IMAGE" --format '{{.Manifest.Digest}}')
echo "base=$b" >> "$GITHUB_OUTPUT"
echo "base: $b"
- name: Compute input hash
id: hash
run: |
set -euo pipefail
h=$(printf '%s\n' \
"${{ steps.up.outputs.base }}" \
"$(sha256sum Dockerfile | cut -d' ' -f1)" \
| sha256sum | cut -c1-12)
echo "hash=$h" >> "$GITHUB_OUTPUT"
echo "input hash: $h"
- name: Compare against what is already published
id: cmp
run: |
set -euo pipefail
if [ "${{ github.event_name }}" != "schedule" ] || [ "${{ inputs.force }}" = "true" ]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "non-scheduled or forced run - building"
exit 0
fi
if docker buildx imagetools inspect "$IMAGE:src-${{ steps.hash.outputs.hash }}" >/dev/null 2>&1; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "no change since last build - skipping"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "upstream or Dockerfile changed - building"
fi
- name: Compute date tag - name: Compute date tag
id: date id: date
run: echo "date=$(date -u +%Y%m%d)" >> "$GITHUB_OUTPUT" run: echo "date=$(date -u +%Y%m%d)" >> "$GITHUB_OUTPUT"
build:
needs: check
if: needs.check.outputs.changed == 'true'
runs-on: ubuntu-docker
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Gitea registry - name: Log in to Gitea registry
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
registry: ${{ vars.REGISTRY_HOST }} registry: ${{ vars.REGISTRY_HOST }}
username: ${{ gitea.actor }} username: ${{ github.actor }}
password: ${{ secrets.REGISTRY_TOKEN }} password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build and push - name: Build and push
@@ -54,13 +110,18 @@ jobs:
with: with:
context: . context: .
push: true push: true
# Two tags: pull: true
# :stable — moving, what callers pull by default provenance: false
# :YYYYMMDD — immutable, for pinning / rollback cache-from: type=registry,ref=${{ env.IMAGE }}:stable
tags: | cache-to: type=inline
${{ vars.REGISTRY_HOST }}/ci-images/fdroidserver-ipfs:stable
${{ vars.REGISTRY_HOST }}/ci-images/fdroidserver-ipfs:${{ steps.date.outputs.date }}
build-args: | build-args: |
IMAGE_SOURCE=https://${{ vars.REGISTRY_HOST }}/ci-images/fdroidserver-ipfs IMAGE_SOURCE=https://${{ vars.REGISTRY_HOST }}/ci-images/fdroidserver-ipfs
cache-from: type=registry,ref=${{ vars.REGISTRY_HOST }}/ci-images/fdroidserver-ipfs:stable FDROIDSERVER_IMAGE=${{ env.FDROIDSERVER_IMAGE }}@${{ needs.check.outputs.base }}
cache-to: type=inline labels: |
org.opencontainers.image.base.name=${{ env.FDROIDSERVER_IMAGE }}
org.opencontainers.image.base.digest=${{ needs.check.outputs.base }}
org.opencontainers.image.revision=${{ github.sha }}
tags: |
${{ env.IMAGE }}:stable
${{ env.IMAGE }}:${{ needs.check.outputs.date }}
${{ env.IMAGE }}:src-${{ needs.check.outputs.hash }}