forked from Conjure-Tools/unity-runner
cleaned docker script
This commit is contained in:
parent
1fae427da1
commit
44706ebef6
@ -32,25 +32,25 @@ jobs:
|
|||||||
- name: Generate Docker Images Table
|
- name: Generate Docker Images Table
|
||||||
run: |
|
run: |
|
||||||
python -c '
|
python -c '
|
||||||
import docker
|
import docker
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
# Connect to Docker registry
|
# Connect to Docker registry
|
||||||
client = docker.from_env()
|
client = docker.from_env()
|
||||||
client.login(
|
client.login(
|
||||||
username=os.environ["DOCKER_USERNAME"],
|
username=os.environ["DOCKER_USERNAME"],
|
||||||
password=os.environ["DOCKER_PASSWORD"],
|
password=os.environ["DOCKER_PASSWORD"],
|
||||||
registry="docker.lakes.house"
|
registry="docker.lakes.house"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Define the base repository
|
# Define the base repository
|
||||||
base_repo = "docker.lakes.house/unityci/editor"
|
base_repo = "docker.lakes.house/unityci/editor"
|
||||||
|
|
||||||
# Get all images
|
# Get all images
|
||||||
images = []
|
images = []
|
||||||
try:
|
try:
|
||||||
# For a real registry we would use the client.images.search, but for private registry
|
# For a real registry we would use the client.images.search, but for private registry
|
||||||
# we need to list tags for the repository
|
# we need to list tags for the repository
|
||||||
# This might require API calls specific to your registry
|
# This might require API calls specific to your registry
|
||||||
@ -58,17 +58,17 @@ try:
|
|||||||
response = client.api.get_registry_data(base_repo)
|
response = client.api.get_registry_data(base_repo)
|
||||||
for tag in response.get("tags", []):
|
for tag in response.get("tags", []):
|
||||||
images.append(f"{base_repo}:{tag}")
|
images.append(f"{base_repo}:{tag}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error listing images: {e}")
|
print(f"Error listing images: {e}")
|
||||||
# Fallback approach or error handling
|
# Fallback approach or error handling
|
||||||
|
|
||||||
# Process images to extract Unity versions and platforms
|
# Process images to extract Unity versions and platforms
|
||||||
unity_platforms = defaultdict(set)
|
unity_platforms = defaultdict(set)
|
||||||
image_map = defaultdict(dict)
|
image_map = defaultdict(dict)
|
||||||
|
|
||||||
pattern = re.compile(r"ubuntu-(\d+\.\d+\.\d+\w*)-(\w+)-runner")
|
pattern = re.compile(r"ubuntu-(\d+\.\d+\.\d+\w*)-(\w+)-runner")
|
||||||
|
|
||||||
for image in images:
|
for image in images:
|
||||||
match = pattern.search(image)
|
match = pattern.search(image)
|
||||||
if match:
|
if match:
|
||||||
unity_version = match.group(1)
|
unity_version = match.group(1)
|
||||||
@ -76,29 +76,29 @@ for image in images:
|
|||||||
unity_platforms[unity_version].add(platform)
|
unity_platforms[unity_version].add(platform)
|
||||||
image_map[unity_version][platform] = image
|
image_map[unity_version][platform] = image
|
||||||
|
|
||||||
# Get all unique platforms
|
# Get all unique platforms
|
||||||
all_platforms = set()
|
all_platforms = set()
|
||||||
for platforms in unity_platforms.values():
|
for platforms in unity_platforms.values():
|
||||||
all_platforms.update(platforms)
|
all_platforms.update(platforms)
|
||||||
all_platforms = sorted(list(all_platforms))
|
all_platforms = sorted(list(all_platforms))
|
||||||
|
|
||||||
# Generate markdown table
|
# Generate markdown table
|
||||||
markdown = "# Unity Docker Images\n\n"
|
markdown = "# Unity Docker Images\n\n"
|
||||||
markdown += "A table of available Docker images for Unity CI/CD:\n\n"
|
markdown += "A table of available Docker images for Unity CI/CD:\n\n"
|
||||||
markdown += "| Unity Version |"
|
markdown += "| Unity Version |"
|
||||||
|
|
||||||
# Add platform headers
|
# Add platform headers
|
||||||
for platform in all_platforms:
|
for platform in all_platforms:
|
||||||
markdown += f" {platform} |"
|
markdown += f" {platform} |"
|
||||||
markdown += "\n|"
|
markdown += "\n|"
|
||||||
|
|
||||||
# Add separator row
|
# Add separator row
|
||||||
for _ in range(len(all_platforms) + 1):
|
for _ in range(len(all_platforms) + 1):
|
||||||
markdown += " --- |"
|
markdown += " --- |"
|
||||||
markdown += "\n"
|
markdown += "\n"
|
||||||
|
|
||||||
# Add rows for each Unity version
|
# Add rows for each Unity version
|
||||||
for unity_version in sorted(unity_platforms.keys()):
|
for unity_version in sorted(unity_platforms.keys()):
|
||||||
markdown += f"| {unity_version} |"
|
markdown += f"| {unity_version} |"
|
||||||
|
|
||||||
for platform in all_platforms:
|
for platform in all_platforms:
|
||||||
@ -110,11 +110,11 @@ for unity_version in sorted(unity_platforms.keys()):
|
|||||||
|
|
||||||
markdown += "\n"
|
markdown += "\n"
|
||||||
|
|
||||||
# Write to README.md
|
# Write to README.md
|
||||||
with open("README.md", "w") as f:
|
with open("README.md", "w") as f:
|
||||||
f.write(markdown)
|
f.write(markdown)
|
||||||
|
|
||||||
print("README updated successfully!")
|
print("README updated successfully!")
|
||||||
'
|
'
|
||||||
|
|
||||||
- name: Commit changes if README was updated
|
- name: Commit changes if README was updated
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user