From 97b78d87af18c0e0f15f1d0798ef4091466d2ec2 Mon Sep 17 00:00:00 2001 From: Philipp Traber Date: Sat, 17 Oct 2026 13:03:31 +0200 Subject: [PATCH] use reusable workflow --- .gitea/workflows/build.yaml | 61 ------------------------------------- .gitea/workflows/image.yaml | 26 ++++++++++++++++ 2 files changed, 26 insertions(+), 61 deletions(-) delete mode 100644 .gitea/workflows/build.yaml create mode 100644 .gitea/workflows/image.yaml diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml deleted file mode 100644 index 0d8f852..0000000 --- a/.gitea/workflows/build.yaml +++ /dev/null @@ -1,61 +0,0 @@ -name: build - -on: - push: - branches: [main] - tags: ["v*"] - workflow_dispatch: - -env: - IMAGE: registry.traberph.de/public/homepage - # Baked in at build time (canonical URLs); override with a repository variable. - SITE_URL: ${{ vars.SITE_URL || 'https://traberph.de' }} - # Default Harbor instance baked into the image as an env var (overridable at runtime). - HARBOR_URL: ${{ vars.HARBOR_URL || 'https://registry.traberph.de' }} - -jobs: - image: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v7 - - # Tag scheme for Flux image automation: -, - # e.g. 20260926154233-1a2b3c4. Timestamps sort numerically, see README. - - name: Compute tags - id: tags - run: | - ts="$(date -u +%Y%m%d%H%M%S)" - sha="$(git rev-parse --short=7 HEAD)" - tags="${IMAGE}:${ts}-${sha}" - if [ "${GITHUB_REF_TYPE}" = "tag" ]; then - tags="${tags},${IMAGE}:${GITHUB_REF_NAME}" - else - tags="${tags},${IMAGE}:latest" - fi - echo "tags=${tags}" >> "$GITHUB_OUTPUT" - echo "created=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$GITHUB_OUTPUT" - echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" - echo "Tags: ${tags}" - - - uses: docker/setup-qemu-action@v4 - - uses: docker/setup-buildx-action@v4 - - - uses: docker/login-action@v4 - with: - registry: registry.traberph.de - username: ${{ secrets.REGISTRY_USERNAME }} - password: ${{ secrets.REGISTRY_TOKEN }} - - - uses: docker/build-push-action@v7 - with: - context: . - platforms: linux/amd64,linux/arm64 - push: true - tags: ${{ steps.tags.outputs.tags }} - build-args: | - SITE_URL=${{ env.SITE_URL }} - HARBOR_URL=${{ env.HARBOR_URL }} - labels: | - org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} - org.opencontainers.image.revision=${{ steps.tags.outputs.sha }} - org.opencontainers.image.created=${{ steps.tags.outputs.created }} diff --git a/.gitea/workflows/image.yaml b/.gitea/workflows/image.yaml new file mode 100644 index 0000000..18cd53a --- /dev/null +++ b/.gitea/workflows/image.yaml @@ -0,0 +1,26 @@ +name: build + +on: + push: + branches: [main] + tags: ["v*"] + workflow_dispatch: + +jobs: + # Tags and build steps are shared across repos, see traberph/ci. + image: + uses: traberph/ci/.gitea/workflows/image.yaml@main + with: + project: public + image: homepage + # SITE_URL is compiled in (canonical URLs); HARBOR_URL is the default Harbor + # instance, still overridable at runtime. Override either with a repository variable. + build-args: | + SITE_URL=${{ vars.SITE_URL || 'https://traberph.de' }} + HARBOR_URL=${{ vars.HARBOR_URL || 'https://registry.traberph.de' }} + secrets: + registry-username: ${{ secrets.REGISTRY_USERNAME }} + registry-token: ${{ secrets.REGISTRY_TOKEN }} + # Public image, so it is mirrored to Docker Hub too. + dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}