Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add arg to remove unsupported Dockerfiles/versions #584

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/updater.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
run: "pip3 install -r requirements.txt"

- name: Run updater
run: "python3 generate_dockerfiles.py"
run: "python3 generate_dockerfiles.py --force"

- uses: gr2m/create-or-update-pull-request-action@86ec1766034c8173518f61d2075cc2a173fb8c97 # v1.9.4
env:
Expand Down
24 changes: 23 additions & 1 deletion generate_dockerfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,31 @@

import os

import argparse
import shutil
import requests_cache
import requests
import yaml
from jinja2 import Environment, FileSystemLoader

requests_cache.install_cache("adoptium_cache", expire_after=3600)

parser = argparse.ArgumentParser(
description="Generate Dockerfiles for Eclipse Temurin images"
)

# Setup the Jinja2 environment
env = Environment(loader=FileSystemLoader("docker_templates"))

headers = {
"User-Agent": "Adoptium Dockerfile Updater",
}

# Flag for force removing old Dockerfiles
parser.add_argument("--force", action="store_true", help="Force remove old Dockerfiles")

args = parser.parse_args()


def archHelper(arch, os_name):
if arch == "aarch64" and os_name == "ubuntu":
Expand All @@ -44,6 +55,15 @@ def archHelper(arch, os_name):
return arch


# Remove old Dockerfiles if --force is set
if args.force:
# Remove all top level dirs that are numbers
for dir in os.listdir():
if dir.isdigit():
print(f"Removing {dir}")
shutil.rmtree(dir)


# Load the YAML configuration
with open("config/hotspot.yml", "r") as file:
config = yaml.safe_load(file)
Expand Down Expand Up @@ -87,7 +107,9 @@ def archHelper(arch, os_name):

# If version doesn't equal 8, get the more accurate version number
if version != 8:
openjdk_version = "jdk-" + release["version_data"]["openjdk_version"]
openjdk_version = (
"jdk-" + release["version_data"]["openjdk_version"]
)
# if openjdk_version contains -LTS remove it
if "-LTS" in openjdk_version:
openjdk_version = openjdk_version.replace("-LTS", "")
Expand Down
Loading