name: Update Hardware List on: schedule: - cron: '0 * * * *' # Run every hour 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: '22' - name: Fetch latest device hardware data id: fetch-data run: | # Define variables for file paths device_hardware_json="app/src/main/assets/device_hardware.json" new_device_hardware_json="/tmp/new_device_hardware.json" # Fetch data from API curl -s --fail https://api.meshtastic.org/resource/deviceHardware > "$new_device_hardware_json" # Ensure the output is valid JSON if ! jq empty "$new_device_hardware_json" 2>/dev/null; then echo "::error::API returned invalid JSON data" exit 1 fi # Check if "$device_hardware_json" exists if [ -f "$device_hardware_json" ]; then # Format both files for consistent comparison jq --sort-keys . "$new_device_hardware_json" > /tmp/new-formatted.json jq --sort-keys . "$device_hardware_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 "device_hardware.json doesn't exist yet" echo "has_changes=true" >> $GITHUB_OUTPUT fi # Copy new data to destination cp "$new_device_hardware_json" "$device_hardware_json" - name: Create Pull Request if: steps.fetch-data.outputs.has_changes == 'true' uses: peter-evans/create-pull-request@v7 with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: "chore: update device hardware list from Meshtastic API" title: "chore: update device hardware list from Meshtastic API" body: | This PR updates the device 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: master delete-branch: true