Skip to content

Commit

Permalink
zentao and wordpress
Browse files Browse the repository at this point in the history
  • Loading branch information
qiaofeng1227 committed Dec 5, 2023
1 parent 47e3f15 commit 72e80df
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 60 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/sync_contentful.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ jobs:
done
if [ -n "$appnames" ]; then
appnames=${appnames:0:-1}
echo $appnames
echo update $appnames
else
echo "update all"
appnames=$(find ./apps -mindepth 1 -maxdepth 1 -type d -exec basename {} \;)
fi
echo "APP_LISTS=$appnames" >> $GITHUB_OUTPUT
Expand Down
2 changes: 1 addition & 1 deletion apps/wordpress/variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{
"dist": "community",
"version": [
"6.3",
"6.4",
"latest"
]
}
Expand Down
2 changes: 1 addition & 1 deletion apps/zentao/variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{
"dist": "community",
"version": [
"18.8",
"18.6",
"latest"
]
}
Expand Down
86 changes: 29 additions & 57 deletions build/sync_contentful.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,67 +50,39 @@ def update_contentful(product_name, editions, requirements):
# 遍历 apps 文件夹下app_lists下的 variables.json 文件
apps_path = Path('apps')
app_lists_str = os.getenv('APP_LISTS', '')
if not app_lists_str: # 如果 app_lists_str 为空
app_lists = app_lists_str.split(',')
for product_name in app_lists:
variables_file = apps_path / product_name / 'variables.json'
try:
with open(variables_file) as file:
data = json.load(file)
editions = data['edition']
requirements = data['requirements']
total_updates += 1
if update_contentful(product_name, editions, requirements):
successful_updates += 1
else:
failed_updates += 1
failed_products.append(product_name)
except FileNotFoundError:
print(f"File not found: {variables_file}")
failed_updates += 1
failed_products.append(product_name)
except json.JSONDecodeError as e:
print(f"JSON decode error in file {variables_file}: {e}")
failed_updates += 1
failed_products.append(product_name)
except Exception as e:
print(f"An unexpected error occurred while processing file {variables_file}: {e}")
failed_updates += 1
failed_products.append(product_name)
app_lists = app_lists_str.split(',')

for product_name in app_lists:
variables_file = apps_path / product_name / 'variables.json'
try:
with open(variables_file) as file:
data = json.load(file)
editions = data['edition']
requirements = data['requirements']

total_updates += 1
if update_contentful(product_name, editions, requirements):
successful_updates += 1
else:
failed_updates += 1
failed_products.append(product_name)
except FileNotFoundError:
print(f"File not found: {variables_file}")
failed_updates += 1
failed_products.append(product_name)
except json.JSONDecodeError as e:
print(f"JSON decode error in file {variables_file}: {e}")
failed_updates += 1
failed_products.append(product_name)
except Exception as e:
print(f"An unexpected error occurred while processing file {variables_file}: {e}")
failed_updates += 1
failed_products.append(product_name)

else:
# 遍历 apps 文件夹中的 variables.json 文件
for variables_file in apps_path.rglob('variables.json'):
try:
with open(variables_file) as file:
data = json.load(file)
product_name = data['name']
editions = data['edition']
requirements = data['requirements']

total_updates += 1
if update_contentful(product_name, editions, requirements):
successful_updates += 1
else:
failed_updates += 1
failed_products.append(product_name)
except json.JSONDecodeError as e:
# 使用父目录的名称来标识出现问题的 JSON 文件
parent_dir_name = variables_file.parent.name
print(f"JSON decode error in file {variables_file}: {e}")
failed_updates += 1
failed_products.append(parent_dir_name) # 使用父目录名作为产品名
except Exception as e:
# 同样,使用父目录的名称来标识出现问题的 JSON 文件
parent_dir_name = variables_file.parent.name
print(f"An unexpected error occurred while processing file {variables_file}: {e}")
failed_updates += 1
failed_products.append(parent_dir_name) # 使用父目录名作为产品名

# 打印更新报告
print(f"Total updates attempted: {total_updates}")
print(f"Successful updates: {successful_updates}")
print(f"Failed updates: {failed_updates}")
if failed_updates > 0:
print(f"Failed products: {failed_products}")
print(f"Failed products: {failed_products}")

0 comments on commit 72e80df

Please sign in to comment.