name: Scheduled Updates (Firmware, Hardware, Translations) on: schedule: - cron: '0 * * * *' # Run every hour workflow_dispatch: # Allow manual triggering jobs: update_assets: runs-on: ubuntu-latest if: github.repository == 'meshtastic/Meshtastic-Android' permissions: contents: write # To commit files and push branches pull-requests: write # To create pull requests steps: - name: Checkout repository uses: actions/checkout@v5 - name: Update firmware releases list run: | firmware_file_path="app/src/main/assets/firmware_releases.json" temp_firmware_file="/tmp/new_firmware_releases.json" echo "Fetching latest firmware releases..." curl -s --fail https://api.meshtastic.org/github/firmware/list > "$temp_firmware_file" if ! jq empty "$temp_firmware_file" 2>/dev/null; then echo "::error::Firmware API returned invalid JSON data. Skipping firmware update." else if [ ! -f "$firmware_file_path" ] || ! jq --sort-keys . "$temp_firmware_file" | diff -q - <(jq --sort-keys . "$firmware_file_path"); then echo "Changes detected in firmware list or local file missing. Updating $firmware_file_path." cp "$temp_firmware_file" "$firmware_file_path" else echo "No changes detected in firmware list." fi fi - name: Update hardware list run: | hardware_file_path="app/src/main/assets/device_hardware.json" temp_hardware_file="/tmp/new_device_hardware.json" echo "Fetching latest device hardware data..." curl -s --fail https://api.meshtastic.org/resource/deviceHardware > "$temp_hardware_file" if ! jq empty "$temp_hardware_file" 2>/dev/null; then echo "::error::Hardware API returned invalid JSON data. Skipping hardware update." else if [ ! -f "$hardware_file_path" ] || ! jq --sort-keys . "$temp_hardware_file" | diff -q - <(jq --sort-keys . "$hardware_file_path"); then echo "Changes detected in hardware list or local file missing. Updating $hardware_file_path." cp "$temp_hardware_file" "$hardware_file_path" else echo "No changes detected in hardware list." fi fi - name: Create Pull Request if changes occurred uses: peter-evans/create-pull-request@v7 with: token: ${{ secrets.AUTOMATION_PAT }} commit-message: | chore: Scheduled updates (Firmware, Hardware) Automated updates for: - Firmware releases list - Device hardware list title: 'chore: Scheduled updates (Firmware, Hardware)' body: | This PR includes automated updates from the scheduled workflow: - Updated `firmware_releases.json` from the Meshtastic API (if changed). - Updated `device_hardware.json` from the Meshtastic API (if changed). Please review the changes. branch: 'scheduled-updates' base: 'main' delete-branch: true labels: | automation firmware hardware