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