automatically build newer nextcloud versions when they have ripened half a year
Some checks failed
Build Nextcloud / get-versions (push) Failing after 7s
Some checks failed
Build Nextcloud / get-versions (push) Failing after 7s
This commit is contained in:
parent
b89324a36a
commit
e1a8728cb6
2 changed files with 71 additions and 3 deletions
|
|
@ -10,16 +10,33 @@ on:
|
|||
- cron: "@daily"
|
||||
|
||||
jobs:
|
||||
get-versions:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: docker.io/library/python:3.14-slim
|
||||
|
||||
outputs:
|
||||
versions: ${{ steps.matrix.outputs.versions }}
|
||||
|
||||
steps:
|
||||
- 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
|
||||
|
|
|
|||
51
nextcloud/get_versions_to_be_built.py
Normal file
51
nextcloud/get_versions_to_be_built.py
Normal 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")
|
||||
Loading…
Reference in a new issue