automatically build newer nextcloud versions when they have ripened half a year
Some checks failed
Build Nextcloud / Determine viable Nextcloud versions (push) Successful in 18s
Build Nextcloud / Build Nextcloud 34 Image (34) (push) Has been cancelled

This commit is contained in:
Max 2026-08-23 21:18:09 +02:00
commit bb2491ffcf
Signed by: max
SSH key fingerprint: SHA256:yZMpYLEULscoVYQvcuxhc3eWa6nymBFWCxjsRErAIY8
2 changed files with 78 additions and 3 deletions

View file

@ -10,16 +10,40 @@ on:
- cron: "@daily"
jobs:
get-versions:
name: Determine viable Nextcloud versions
runs-on: docker
container:
image: docker.io/library/python:3.14-slim
outputs:
versions: ${{ steps.matrix.outputs.versions }}
steps:
- name: Install required system package
run: apt-get update; apt-get install -y --no-install-recommends --no-install-suggests nodejs
- name: Install required pip package
run: pip install requests
- name: Checkout source code
uses: actions/checkout@v7
- name: Generate Nextcloud version matrix
id: matrix
shell: sh
run: python3 ${{ forgejo.workspace }}/nextcloud/get_versions_to_be_built.py
build-container:
name: Build Nextcloud ${{ matrix.nextcloud-version }} Image
runs-on: docker
needs: get-versions
container:
image: ghcr.io/osscontainertools/kaniko:alpine
strategy:
matrix:
nextcloud-version:
# renovate: datasource=docker depName=docker.io/library/nextcloud
- 34
nextcloud-version: ${{ fromJSON(needs.get-versions.outputs.versions) }}
steps:
- name: Install required system packages
run: apk add --no-cache nodejs git

View file

@ -0,0 +1,51 @@
import datetime
import json
import os
import re
import requests
endoflife_nextcloud_url = "https://endoflife.date/api/v1/products/nextcloud/"
ansible_nextcloud_vars_url = "https://git.hamburg.ccc.de/CCCHH/ansible-infra/raw/branch/main/inventories/chaosknoten/host_vars/cloud.yaml"
ansible_nextcloud_vars_regex = r"(?m)^\s*nextcloud__version:\s*(\d+)\s*$"
releases_to_be_built = []
# get the currently installed Nextcloud version
nc_vars = requests.get(ansible_nextcloud_vars_url).text
match = re.search(ansible_nextcloud_vars_regex, nc_vars)
if match:
current_version = int(match.group(1))
releases_to_be_built.append(current_version)
else:
raise ValueError("nextcloud__version not found")
# determine the current Nextcloud versions
eol_data = requests.get(endoflife_nextcloud_url).text
eol_json = json.loads(eol_data)
now = datetime.datetime.now()
format_string = '%Y-%m-%d'
viable_releases = []
for release in eol_json["result"]["releases"]:
# only check releases which are not EOL
if release['isEol'] is True:
continue
# parse release date
release_datetime = datetime.datetime.strptime(release['releaseDate'], format_string)
# only consider releases older than half a year
if release_datetime < now - datetime.timedelta(days=180):
version = int(release['name'])
print(f"{version} released on {release['releaseDate']}")
if version > current_version:
releases_to_be_built.append(version)
versions = [str(v) for v in releases_to_be_built]
print(versions)
with open(os.environ["FORGEJO_OUTPUT"], "a") as output:
output.write(f"versions={json.dumps(versions)}\n")