From 45ad2d4730c577ea111d752dfd8454945ba7793f Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Sun, 9 Nov 2025 18:55:22 +0100 Subject: [PATCH] build on github --- .gitea/workflows/release.yaml | 95 ----------------------- .github/workflows/release.yaml | 137 +++++++++++++++++++++++++++++++++ k8s/papercrate/values.yaml | 6 +- 3 files changed, 140 insertions(+), 98 deletions(-) delete mode 100644 .gitea/workflows/release.yaml create mode 100644 .github/workflows/release.yaml diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml deleted file mode 100644 index c628649..0000000 --- a/.gitea/workflows/release.yaml +++ /dev/null @@ -1,95 +0,0 @@ -name: ci - -on: - push: - branches: - - main - - staging - - dev - tags: - - '*' - -jobs: - docker: - runs-on: ubuntu-latest - strategy: - matrix: - include: - - service: frontend - context: frontend - dockerfile: frontend/Dockerfile - - service: backend - context: backend - dockerfile: backend/Dockerfile - - steps: - - name: Checkout with submodules - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Derive repository metadata - id: repo_meta - run: | - repo="${GITHUB_REPOSITORY:-$GITEA_REPOSITORY}" - owner="${repo%%/*}" - name="${repo##*/}" - echo "repo_owner=$owner" >> "$GITHUB_OUTPUT" - echo "repo_name=$name" >> "$GITHUB_OUTPUT" - - - name: Compute base tag - id: compute_tag - run: | - sha="${GITHUB_SHA:-$GITEA_SHA}" - ref_type="${GITHUB_REF_TYPE:-$GITEA_REF_TYPE}" - ref_name="${GITHUB_REF_NAME:-$GITEA_REF_NAME}" - - if [ -z "$sha" ]; then - echo "base_tag=$ref_name" >> "$GITHUB_OUTPUT" - exit 0 - fi - - short="${sha:0:7}" - tag="$short" - - if [ "$ref_type" = "tag" ]; then - tag="$ref_name" - elif [ "$ref_name" = "dev" ]; then - tag="${tag}-dev" - fi - - echo "base_tag=$tag" >> "$GITHUB_OUTPUT" - - - name: Login to local registry - uses: docker/login-action@v2 - with: - registry: ${{ vars.REGISTRY_URL }} - username: ${{ vars.REGISTRY_USER }} - password: ${{ secrets.REGISTRY_PASSWORD }} - - - name: Login to GHCR - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ vars.GHCR_USERNAME }} - password: ${{ secrets.GHCR_PASSWORD }} - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - with: - driver: remote - endpoint: ${{ env.BUILDKIT_ARM64_ENDPOINT }} - - - name: Build and Push ${{ matrix.service }} Image - uses: docker/build-push-action@v6 - with: - context: ${{ matrix.context }} - file: ${{ matrix.dockerfile }} - platforms: linux/arm64 - push: true - provenance: false - tags: | - ${{ vars.REGISTRY_URL }}/${{ steps.repo_meta.outputs.repo_name }}-${{ matrix.service }}:${{ steps.compute_tag.outputs.base_tag }} - ${{ vars.REGISTRY_URL }}/${{ steps.repo_meta.outputs.repo_name }}-${{ matrix.service }}:${{ gitea.sha }} - ghcr.io/paperless-dms/${{ steps.repo_meta.outputs.repo_name }}-${{ matrix.service }}:${{ steps.compute_tag.outputs.base_tag }} - ghcr.io/paperless-dms/${{ steps.repo_meta.outputs.repo_name }}-${{ matrix.service }}:${{ gitea.sha }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..7e9fe11 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,137 @@ +name: ci + +on: + push: + branches: + - main + - staging + - dev + tags: + - '*' + +jobs: + docker: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + strategy: + matrix: + include: + - service: frontend + context: frontend + dockerfile: frontend/Dockerfile + - service: backend + context: backend + dockerfile: backend/Dockerfile + + steps: + - name: Checkout with submodules + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Derive repository metadata + id: repo_meta + run: | + repo="${GITHUB_REPOSITORY}" + owner="${repo%%/*}" + name="${repo##*/}" + echo "repo_owner=$owner" >> "$GITHUB_OUTPUT" + echo "repo_name=$name" >> "$GITHUB_OUTPUT" + + - name: Compute base tag + id: compute_tag + env: + GITHUB_SHA: ${{ github.sha }} + GITHUB_REF_TYPE: ${{ github.ref_type }} + GITHUB_REF_NAME: ${{ github.ref_name }} + run: | + sha="${GITHUB_SHA}" + ref_type="${GITHUB_REF_TYPE}" + ref_name="${GITHUB_REF_NAME}" + + short="${sha:0:7}" + tag="$short" + + if [ "$ref_type" = "tag" ]; then + tag="$ref_name" + elif [ "$ref_name" = "dev" ]; then + tag="${tag}-dev" + elif [ "$ref_name" = "staging" ]; then + tag="${tag}-staging" + fi + + echo "base_tag=$tag" >> "$GITHUB_OUTPUT" + + - name: Login to local registry + uses: docker/login-action@v2 + with: + registry: ${{ vars.REGISTRY_URL }} + username: ${{ vars.REGISTRY_USER }} + password: ${{ secrets.REGISTRY_PASSWORD }} + + - name: Login to GHCR + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ vars.GHCR_USERNAME }} + password: ${{ secrets.GHCR_PASSWORD }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Determine branch alias tag + id: branch_alias + env: + REF_NAME: ${{ github.ref_name }} + run: | + alias="" + case "${REF_NAME}" in + dev) alias="latest-dev" ;; + staging) alias="latest-staging" ;; + main) alias="latest" ;; + esac + echo "alias=$alias" >> "$GITHUB_OUTPUT" + + - name: Assemble image tags + id: tag_list + env: + REGISTRY_URL: ${{ vars.REGISTRY_URL }} + REPO_NAME: ${{ steps.repo_meta.outputs.repo_name }} + SERVICE: ${{ matrix.service }} + BASE_TAG: ${{ steps.compute_tag.outputs.base_tag }} + GIT_SHA: ${{ github.sha }} + BRANCH_ALIAS: ${{ steps.branch_alias.outputs.alias }} + run: | + if [ -n "${REGISTRY_URL}" ]; then + repo_tag="${REGISTRY_URL}/${REPO_NAME}-${SERVICE}" + else + repo_tag="${REPO_NAME}-${SERVICE}" + fi + ghcr_tag="ghcr.io/papercrate-dms/${REPO_NAME}-${SERVICE}" + + tags="${repo_tag}:${BASE_TAG}\n${repo_tag}:${GIT_SHA}\n${ghcr_tag}:${BASE_TAG}\n${ghcr_tag}:${GIT_SHA}" + + if [ -n "${BRANCH_ALIAS}" ]; then + tags="${tags}\n${repo_tag}:${BRANCH_ALIAS}\n${ghcr_tag}:${BRANCH_ALIAS}" + fi + + { + echo "tags<<'EOF'" + echo "${tags}" + echo EOF + } >> "$GITHUB_OUTPUT" + + - name: Build and Push ${{ matrix.service }} Image + uses: docker/build-push-action@v6 + with: + context: ${{ matrix.context }} + file: ${{ matrix.dockerfile }} + platforms: linux/amd64,linux/arm64 + push: true + provenance: false + tags: ${{ steps.tag_list.outputs.tags }} diff --git a/k8s/papercrate/values.yaml b/k8s/papercrate/values.yaml index 3d4f27a..67c747c 100644 --- a/k8s/papercrate/values.yaml +++ b/k8s/papercrate/values.yaml @@ -12,7 +12,7 @@ global: backend: replicaCount: 1 image: - repository: registry.example.com/papercrate-backend + repository: ghcr.io/papercrate-dms/papercrate-backend tag: "" pullPolicy: IfNotPresent service: @@ -32,7 +32,7 @@ webdav: enabled: true replicaCount: 1 image: - repository: registry.example.com/papercrate-backend + repository: ghcr.io/papercrate-dms/papercrate-backend tag: "" pullPolicy: IfNotPresent service: @@ -63,7 +63,7 @@ frontend: enabled: true replicaCount: 1 image: - repository: registry.example.com/papercrate-frontend + repository: ghcr.io/papercrate-dms/papercrate-frontend tag: "" pullPolicy: IfNotPresent service: