1+ name : Update Hardware List
2+
3+ on :
4+ schedule :
5+ - cron : ' 0 * * * *' # Run every hour
6+ workflow_dispatch : # Allow manual triggering
7+
8+ jobs :
9+ update-hardware-list :
10+ runs-on : ubuntu-latest
11+ permissions :
12+ contents : write
13+ pull-requests : write
14+
15+ steps :
16+ - name : Checkout repository
17+ uses : actions/checkout@v4
18+
19+ - name : Set up Node.js
20+ uses : actions/setup-node@v4
21+ with :
22+ node-version : ' 18'
23+
24+ - name : Fetch latest device hardware data
25+ id : fetch-data
26+ run : |
27+ # Fetch data from API
28+ curl -s --fail https://api.meshtastic.org/resource/deviceHardware > /tmp/new-hardware-list.json
29+
30+ # Ensure the output is valid JSON
31+ if ! jq empty /tmp/new-hardware-list.json 2>/dev/null; then
32+ echo "::error::API returned invalid JSON data"
33+ exit 1
34+ fi
35+
36+ # Check if public/data/hardware-list.json exists
37+ if [ -f "public/data/hardware-list.json" ]; then
38+ # Format both files for consistent comparison
39+ jq --sort-keys . /tmp/new-hardware-list.json > /tmp/new-formatted.json
40+ jq --sort-keys . public/data/hardware-list.json > /tmp/existing-formatted.json
41+
42+ # Compare files
43+ if cmp -s /tmp/new-formatted.json /tmp/existing-formatted.json; then
44+ echo "No changes detected in hardware list"
45+ echo "has_changes=false" >> $GITHUB_OUTPUT
46+ else
47+ echo "Changes detected in hardware list"
48+ echo "has_changes=true" >> $GITHUB_OUTPUT
49+ fi
50+ else
51+ echo "hardware-list.json doesn't exist yet"
52+ echo "has_changes=true" >> $GITHUB_OUTPUT
53+ fi
54+
55+ # Copy new data to destination
56+ cp /tmp/new-hardware-list.json public/data/hardware-list.json
57+
58+ - name : Create Pull Request
59+ if : steps.fetch-data.outputs.has_changes == 'true'
60+ uses : peter-evans/create-pull-request@v5
61+ with :
62+ token : ${{ secrets.GITHUB_TOKEN }}
63+ commit-message : " chore: update hardware list from Meshtastic API"
64+ title : " chore: update hardware list from Meshtastic API"
65+ body : |
66+ This PR updates the hardware list with the latest data from the Meshtastic API.
67+
68+ This PR was automatically generated by the update-hardware-list workflow.
69+ branch : update-hardware-list
70+ base : main
71+ delete-branch : true
0 commit comments