Skip to content

Update Hardware List #2670

Update Hardware List

Update Hardware List #2670

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