Skip to content

Commit a9d2a67

Browse files
Ignore updates to manual battery types
1 parent c287909 commit a9d2a67

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

.github/workflows/new_device.yaml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,20 @@ jobs:
5757
if new_device.get("battery_type", "").lower() == "rechargable":
5858
new_device["battery_type"] = "Rechargeable"
5959
60-
# Check for duplicates and replace old entry with new one
60+
# Check for duplicates and replace old entry with new one, flagging manual entries
6161
duplicate_found = False
62+
manual_found = False
6263
for i, device in enumerate(devices):
6364
if device["manufacturer"] == new_device["manufacturer"] and device["model"] == new_device["model"] and device.get("model_id", "") == new_device.get("model_id", "") and device.get("hw_version", "") == new_device.get("hw_version", ""):
65+
if device["battery_type"].upper() == "MANUAL":
66+
manual_found = True
67+
break
6468
devices[i] = new_device
6569
duplicate_found = True
6670
break
6771
68-
# If no duplicate found, add the new device to the JSON library file
69-
if not duplicate_found:
72+
# If no duplicate found and not currently manual, add the new device to the JSON library file
73+
if not duplicate_found and not manual_found:
7074
devices.append(new_device)
7175
7276
# Save manufacturer and model for later use
@@ -84,8 +88,11 @@ jobs:
8488
set_env("MODE", "adds")
8589
set_env("TITLE_MODE", "Add")
8690
87-
with open("library/library.json", "w") as f:
88-
f.write(json.dumps(devices_json, indent=4))
91+
set_env("MANUAL", str(manual_found))
92+
93+
if not manual_found:
94+
with open("library/library.json", "w") as f:
95+
f.write(json.dumps(devices_json, indent=4))
8996
9097
- name: Rename Issue
9198
run: |
@@ -99,12 +106,14 @@ jobs:
99106
100107
- name: Validate JSON
101108
uses: docker://orrosenblatt/validate-json-action:latest
109+
if: "${{ env.MANUAL != 'True' }}"
102110
env:
103111
INPUT_SCHEMA: library/schema.json
104112
INPUT_JSONS: library/library.json
105113

106114
- name: Create pull request
107115
uses: peter-evans/create-pull-request@v7
116+
if: "${{ env.MANUAL != 'True' }}"
108117
with:
109118
commit-message: "${{ env.TITLE_MODE }} device: ${{ env.MODEL }} by ${{ env.MANUFACTURER }}"
110119
title: "${{ env.TITLE_MODE }} device: ${{ env.MANUFACTURER }} - ${{ env.MODEL }}"

0 commit comments

Comments
 (0)