Port CI to Forgejo Actions
Some checks failed
ci / build-prod (push) Failing after 0s
ci / chart (push) Failing after 0s
ci / build-dev (push) Successful in 0s
ci / build (push) Successful in 28m23s
ci / version (push) Successful in 7s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Jonas Leder 2026-11-18 10:12:45 +01:00
commit 75f7ad4086
4 changed files with 68 additions and 87 deletions

View file

@ -2,5 +2,5 @@ dockerdata/
docker-compose.yml
Dockerfile
.git
.gitlab-ci.yml
.forgejo
helm/

66
.forgejo/workflows/ci.yml Normal file
View file

@ -0,0 +1,66 @@
name: ci
on:
push:
branches: ['**']
tags: ['**']
workflow_dispatch:
env:
# renovate: datasource=github-releases depName=nextcloud packageName=nextcloud/server
NEXTCLOUD_VERSION: v35.0.3
jobs:
version:
runs-on: default
outputs:
nextcloud: ${{ steps.v.outputs.nextcloud }}
steps:
- id: v
run: echo "nextcloud=${NEXTCLOUD_VERSION#v}" >> "$GITHUB_OUTPUT"
build-dev:
needs: [version]
uses: infra/ci-snippets/.forgejo/workflows/docker-build.yml@master
with:
image-suffix: /nextcloud-dev
# Reuse the PHP extension stages between pipelines; they only rebuild when the base image changes.
additional-args: >-
--opt build-arg:NEXTCLOUD_VERSION=${{ needs.version.outputs.nextcloud }}
--import-cache type=registry,ref=forgejo.jonasled.dev/jonasled/nextcloud/buildcache:dev
--import-cache type=registry,ref=forgejo.jonasled.dev/jonasled/nextcloud/buildcache:prod
--export-cache type=registry,ref=forgejo.jonasled.dev/jonasled/nextcloud/buildcache:dev,mode=max,image-manifest=true,oci-mediatypes=true
secrets: inherit
build-prod:
needs: [version]
if: github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch
uses: infra/ci-snippets/.forgejo/workflows/docker-build.yml@master
with:
image-suffix: /nextcloud
image-tag: ${{ needs.version.outputs.nextcloud }}
additional-args: >-
--opt build-arg:NEXTCLOUD_VERSION=${{ needs.version.outputs.nextcloud }}
--import-cache type=registry,ref=forgejo.jonasled.dev/jonasled/nextcloud/buildcache:dev
--import-cache type=registry,ref=forgejo.jonasled.dev/jonasled/nextcloud/buildcache:prod
--export-cache type=registry,ref=forgejo.jonasled.dev/jonasled/nextcloud/buildcache:prod,mode=max,image-manifest=true,oci-mediatypes=true
secrets: inherit
chart:
# helm install nextcloud oci://forgejo.jonasled.dev/jonasled/nextcloud/charts/nextcloud --version <version>
needs: [version, build-prod]
uses: infra/ci-snippets/.forgejo/workflows/helm-build.yml@master
with:
chart-path: helm
push: true
lint-args: --strict
version-from-run-number: true
version-offset: '741'
app-version: ${{ needs.version.outputs.nextcloud }}
pre-package: |
sed -i "s/^ digest: .*/ digest: ${{ needs.build-prod.outputs.digest }}/" helm/values.yaml
sed -i "s/^appVersion: .*/appVersion: ${{ needs.version.outputs.nextcloud }}/" helm/Chart.yaml
grep -qE "^ digest: sha256:.+" helm/values.yaml || { echo "image digest not set"; exit 1; }
# Render so template failures show up in CI.
extra-checks: helm template ci helm --set nextcloud.admin.password=ci --set postgresql.auth.password.secretName=ci > /dev/null
secrets: inherit

View file

@ -1,85 +0,0 @@
variables:
# Reuse the PHP extension stages between pipelines; they only rebuild when the base image changes.
BUILD_CACHE_ARGS: "--import-cache type=registry,ref=$CI_REGISTRY_IMAGE/buildcache:dev --import-cache type=registry,ref=$CI_REGISTRY_IMAGE/buildcache:prod"
stages:
- build
- test
- bundle
- deploy
BuildDevImage:
image: jonasled.dev/infra/docker-build:master@sha256:d6f535fcb2817edec221eac33331369863f3409322d5f2d516356e7e7554326b
stage: build
needs: []
variables:
# renovate: datasource=github-releases depName=nextcloud packageName=nextcloud/server
NEXTCLOUD_VERSION: v35.0.3
script:
- export NEXTCLOUD_VERSION="${NEXTCLOUD_VERSION#v}"
- export IMAGE_NAME=$CI_REGISTRY_IMAGE/nextcloud-dev
- export BUILDKIT_ADDITIONAL_ARGS="--opt build-arg:NEXTCLOUD_VERSION=$NEXTCLOUD_VERSION $BUILD_CACHE_ARGS --export-cache type=registry,ref=$CI_REGISTRY_IMAGE/buildcache:dev,mode=max,image-manifest=true,oci-mediatypes=true"
- build-image
artifacts:
paths:
- image-scan-report.bom.json
- image-hash.txt
- scan-report.json
reports:
codequality: scan-report.json
BuildProdImage:
image: jonasled.dev/infra/docker-build:master@sha256:d6f535fcb2817edec221eac33331369863f3409322d5f2d516356e7e7554326b
stage: build
needs: []
variables:
# renovate: datasource=github-releases depName=nextcloud packageName=nextcloud/server
NEXTCLOUD_VERSION: v35.0.3
script:
- export NEXTCLOUD_VERSION="${NEXTCLOUD_VERSION#v}"
- export IMAGE_NAME=$CI_REGISTRY_IMAGE/nextcloud
- export BUILDKIT_ADDITIONAL_ARGS="--opt build-arg:NEXTCLOUD_VERSION=$NEXTCLOUD_VERSION $BUILD_CACHE_ARGS --export-cache type=registry,ref=$CI_REGISTRY_IMAGE/buildcache:prod,mode=max,image-manifest=true,oci-mediatypes=true"
- export IMAGE_TAG=$NEXTCLOUD_VERSION
- build-image
artifacts:
paths:
- image-hash.txt
rules:
- if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
HelmChart:
# Packages the chart and pushes it to the project's OCI registry:
# helm install nextcloud oci://$CI_REGISTRY/$CI_PROJECT_PATH/charts/nextcloud --version <version>
# Versions must only grow, so the patch number is the pipeline IID; major.minor comes from Chart.yaml.
image:
name: alpine/helm:4.3.2
entrypoint: [""]
stage: bundle
needs:
- BuildProdImage
dependencies:
- BuildProdImage
variables:
# renovate: datasource=github-releases depName=nextcloud packageName=nextcloud/server
NEXTCLOUD_VERSION: v35.0.3
CHART_DIR: helm
CHART_REPO: oci://$CI_REGISTRY/$CI_PROJECT_PATH/charts
script:
- export NEXTCLOUD_VERSION="${NEXTCLOUD_VERSION#v}"
- 'sed -i "s/^ digest: .*/ digest: $(cat image-hash.txt)/" "$CHART_DIR/values.yaml"'
- 'sed -i "s/^appVersion: .*/appVersion: $NEXTCLOUD_VERSION/" "$CHART_DIR/Chart.yaml"'
- 'grep -qE "^ digest: .+" "$CHART_DIR/values.yaml" || { echo "image digest not set"; exit 1; }'
- helm lint "$CHART_DIR" --strict
# Render so template failures show up in CI.
- helm template ci "$CHART_DIR" --set nextcloud.admin.password=ci --set postgresql.auth.password.secretName=ci > /dev/null
- |
BASE_VERSION=$(sed -n 's/^version: *//p' "$CHART_DIR/Chart.yaml" | cut -d. -f1,2)
helm package "$CHART_DIR" --version "${BASE_VERSION}.${CI_PIPELINE_IID}" --destination dist
- helm registry login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
- helm push dist/nextcloud-*.tgz "$CHART_REPO"
artifacts:
paths:
- dist/
rules:
- if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

View file

@ -5,7 +5,7 @@
replicaCount: 1
image:
repository: jonasled.dev/jonasled/nextcloud/nextcloud
repository: forgejo.jonasled.dev/jonasled/nextcloud/nextcloud
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""