Skip to content

Commit 63e246f

Browse files
committed
feat: add force build support to update_containers workflow
1 parent 17a1916 commit 63e246f

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

.github/workflows/update_containers.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ on:
44
schedule:
55
- cron: '0 0 * * 0' # Weekly on Sunday
66
workflow_dispatch:
7+
inputs:
8+
force:
9+
description: 'Force build all images'
10+
type: boolean
11+
default: false
712

813
permissions:
914
contents: write
@@ -25,7 +30,12 @@ jobs:
2530

2631
- name: Run update script
2732
id: update
28-
run: uv run scripts/update_containers.py
33+
run: |
34+
FORCE_FLAG=""
35+
if [[ "${{ github.event.inputs.force }}" == "true" ]]; then
36+
FORCE_FLAG="--force"
37+
fi
38+
uv run scripts/update_containers.py $FORCE_FLAG
2939
env:
3040
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3141

scripts/update_containers.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import argparse
34
import json
45
import os
56
import re
@@ -8,7 +9,7 @@
89
from pathlib import Path
910

1011

11-
def update_container_file(server_name: str, version: str) -> bool:
12+
def update_container_file(server_name: str, version: str, force: bool = False) -> bool:
1213
container_file = Path(f"container/{server_name}/ContainerFile")
1314
if not container_file.exists():
1415
print(f"ContainerFile for {server_name} not found at {container_file}")
@@ -17,15 +18,19 @@ def update_container_file(server_name: str, version: str) -> bool:
1718
content = container_file.read_text()
1819
new_content = re.sub(r"ARG VERSION=.*", f"ARG VERSION={version}", content, count=1)
1920

20-
if content != new_content:
21+
updated = content != new_content
22+
if updated:
2123
container_file.write_text(new_content)
2224
print(f"Updated {server_name} to {version}")
23-
return True
2425

25-
return False
26+
return updated or force
2627

2728

2829
def main():
30+
parser = argparse.ArgumentParser()
31+
parser.add_argument("--force", action="store_true", help="Force update all servers")
32+
args = parser.parse_args()
33+
2934
# Capture the output of server_versions.py
3035
result = subprocess.run(
3136
[sys.executable, "scripts/server_versions.py"],
@@ -37,7 +42,7 @@ def main():
3742

3843
updated_servers = []
3944
for server, version in versions.items():
40-
if update_container_file(server, version):
45+
if update_container_file(server, version, args.force):
4146
updated_servers.append(server)
4247

4348
if updated_servers:

0 commit comments

Comments
 (0)