refactor: improve manifest.json generation and update check for changes
This commit is contained in:
@@ -57,7 +57,9 @@ jobs:
|
||||
run: |
|
||||
MAIN_FILE="${{ inputs.main_file }}"
|
||||
python3 - <<'PY'
|
||||
import json, re, os
|
||||
import json, os, re
|
||||
from pathlib import Path
|
||||
|
||||
main_file = os.environ["MAIN_FILE"]
|
||||
|
||||
with open(main_file, "r", encoding="utf-8") as handle:
|
||||
@@ -78,17 +80,21 @@ jobs:
|
||||
"author_url": read_field("Author URI"),
|
||||
}
|
||||
|
||||
with open("manifest.json", "w", encoding="utf-8") as handle:
|
||||
json.dump(manifest, handle, ensure_ascii=False, indent=2)
|
||||
output = json.dumps(manifest, ensure_ascii=False, indent=2)
|
||||
path = Path("manifest.json")
|
||||
|
||||
print("manifest.json aangemaakt/bijgewerkt")
|
||||
if path.exists() and path.read_text(encoding="utf-8") == output:
|
||||
print("manifest.json ongewijzigd")
|
||||
else:
|
||||
path.write_text(output, encoding="utf-8")
|
||||
print("manifest.json aangemaakt/bijgewerkt")
|
||||
PY
|
||||
env:
|
||||
MAIN_FILE: ${{ inputs.main_file }}
|
||||
|
||||
- name: Commit & push manifest.json (optioneel)
|
||||
run: |
|
||||
if git diff --quiet -- manifest.json; then
|
||||
if ! git status --short -- manifest.json | grep -q .; then
|
||||
echo "manifest.json ongewijzigd; geen commit nodig."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user