mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
feat: Add GitHub workflow to update hardware list (#1802)
This commit is contained in:
parent
ace756b96a
commit
551f7cb1c4
2 changed files with 76 additions and 0 deletions
1
.github/workflows/crowdin.yml
vendored
1
.github/workflows/crowdin.yml
vendored
|
|
@ -3,6 +3,7 @@ name: Crowdin Action
|
|||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
workflow_dispatch: # Allow manual triggering
|
||||
|
||||
jobs:
|
||||
synchronize-with-crowdin:
|
||||
|
|
|
|||
75
.github/workflows/update-hardware-list.yml
vendored
Normal file
75
.github/workflows/update-hardware-list.yml
vendored
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
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: '18'
|
||||
|
||||
- name: Fetch latest device hardware data
|
||||
id: fetch-data
|
||||
run: |
|
||||
# Define variables for file paths
|
||||
device_hardware_json="public/data/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@v5
|
||||
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: main
|
||||
delete-branch: true
|
||||
Loading…
Add table
Add a link
Reference in a new issue