forked from Conjure-Tools/unity-runner
silly readme test
This commit is contained in:
parent
7d249ff53a
commit
1fae427da1
125
.gitea/workflows/update-readme.yaml
Normal file
125
.gitea/workflows/update-readme.yaml
Normal file
@ -0,0 +1,125 @@
|
||||
name: Update README with Docker Images
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 0 * * *' # Run daily at midnight
|
||||
workflow_dispatch: # Allow manual triggering
|
||||
|
||||
jobs:
|
||||
update-readme:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.10'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install docker
|
||||
|
||||
- name: Log in to Docker Registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: docker.lakes.house
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Generate Docker Images Table
|
||||
run: |
|
||||
python -c '
|
||||
import docker
|
||||
import re
|
||||
import os
|
||||
from collections import defaultdict
|
||||
|
||||
# Connect to Docker registry
|
||||
client = docker.from_env()
|
||||
client.login(
|
||||
username=os.environ["DOCKER_USERNAME"],
|
||||
password=os.environ["DOCKER_PASSWORD"],
|
||||
registry="docker.lakes.house"
|
||||
)
|
||||
|
||||
# Define the base repository
|
||||
base_repo = "docker.lakes.house/unityci/editor"
|
||||
|
||||
# Get all images
|
||||
images = []
|
||||
try:
|
||||
# For a real registry we would use the client.images.search, but for private registry
|
||||
# we need to list tags for the repository
|
||||
# This might require API calls specific to your registry
|
||||
# For this example, we assume we can get a list of tags
|
||||
response = client.api.get_registry_data(base_repo)
|
||||
for tag in response.get("tags", []):
|
||||
images.append(f"{base_repo}:{tag}")
|
||||
except Exception as e:
|
||||
print(f"Error listing images: {e}")
|
||||
# Fallback approach or error handling
|
||||
|
||||
# Process images to extract Unity versions and platforms
|
||||
unity_platforms = defaultdict(set)
|
||||
image_map = defaultdict(dict)
|
||||
|
||||
pattern = re.compile(r"ubuntu-(\d+\.\d+\.\d+\w*)-(\w+)-runner")
|
||||
|
||||
for image in images:
|
||||
match = pattern.search(image)
|
||||
if match:
|
||||
unity_version = match.group(1)
|
||||
platform = match.group(2)
|
||||
unity_platforms[unity_version].add(platform)
|
||||
image_map[unity_version][platform] = image
|
||||
|
||||
# Get all unique platforms
|
||||
all_platforms = set()
|
||||
for platforms in unity_platforms.values():
|
||||
all_platforms.update(platforms)
|
||||
all_platforms = sorted(list(all_platforms))
|
||||
|
||||
# Generate markdown table
|
||||
markdown = "# Unity Docker Images\n\n"
|
||||
markdown += "A table of available Docker images for Unity CI/CD:\n\n"
|
||||
markdown += "| Unity Version |"
|
||||
|
||||
# Add platform headers
|
||||
for platform in all_platforms:
|
||||
markdown += f" {platform} |"
|
||||
markdown += "\n|"
|
||||
|
||||
# Add separator row
|
||||
for _ in range(len(all_platforms) + 1):
|
||||
markdown += " --- |"
|
||||
markdown += "\n"
|
||||
|
||||
# Add rows for each Unity version
|
||||
for unity_version in sorted(unity_platforms.keys()):
|
||||
markdown += f"| {unity_version} |"
|
||||
|
||||
for platform in all_platforms:
|
||||
if platform in image_map[unity_version]:
|
||||
image_name = image_map[unity_version][platform].split("/")[-1]
|
||||
markdown += f" `{image_name}` |"
|
||||
else:
|
||||
markdown += " - |"
|
||||
|
||||
markdown += "\n"
|
||||
|
||||
# Write to README.md
|
||||
with open("README.md", "w") as f:
|
||||
f.write(markdown)
|
||||
|
||||
print("README updated successfully!")
|
||||
'
|
||||
|
||||
- name: Commit changes if README was updated
|
||||
run: |
|
||||
git config --local user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git config --local user.name "github-actions[bot]"
|
||||
git add README.md
|
||||
git diff --quiet && git diff --staged --quiet || (git commit -m "Update Docker images table in README" && git push)
|
||||
Loading…
x
Reference in New Issue
Block a user