Skip to content

Update Flight Controller IDs #105

Update Flight Controller IDs

Update Flight Controller IDs #105

name: Update Flight Controller IDs
on:
workflow_dispatch:
schedule:
- cron: '30 3 * * 1,4' # Every Monday and Thursday at 3:30 AM
permissions:
contents: read
jobs:
update-ids:
permissions:
contents: write # for Git to git push
pull-requests: write # for creating PRs
runs-on: ubuntu-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
with:
egress-policy: audit
- name: Checkout MethodicConfigurator
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Checkout ArduPilot
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: ArduPilot/ardupilot
path: ardupilot
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.x'
- name: Install dependencies
id: install_deps
continue-on-error: true
run: |
WARNINGS=0
export PIP_VERSION=$(grep -oP 'pip\s*==\s*\K[0-9]+(\.[0-9]+)*' pyproject.toml | head -1 || echo '')
if [ -z "$PIP_VERSION" ]; then
echo "::warning::Could not detect pip version in pyproject.toml; falling back to latest."
PIP_INSTALL="pip"
WARNINGS=1
else
echo "Will install pip version $PIP_VERSION."
PIP_INSTALL="pip==$PIP_VERSION"
fi
python -m pip install "$PIP_INSTALL"
mv ardupilot ..
echo "warnings=$WARNINGS" >> $GITHUB_OUTPUT
if [ "$WARNINGS" -eq 1 ]; then
exit 1
fi
- name: Update flight controller IDs
run: python update_flight_controller_ids.py
- name: Stage changes
id: stage_changes
run: |
git add ardupilot_methodic_configurator/data_model_fc_ids.py
CHANGED_LINES=$(git diff --staged | grep -E "^[\+\-]" | wc -l)
echo "CHANGED_LINES=$CHANGED_LINES" >> $GITHUB_OUTPUT
if [ $CHANGED_LINES -gt 3 ]; then
echo "HAS_CHANGES=true" >> $GITHUB_OUTPUT
else
echo "Not enough changes to commit (only $CHANGED_LINES lines changed)"
echo "HAS_CHANGES=false" >> $GITHUB_OUTPUT
fi
- name: Create Pull Request
if: steps.stage_changes.outputs.HAS_CHANGES == 'true'
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
labels: flightcontroller-IDs, automated-pr
branch: update/flight-controller-ids
title: "Update ArduPilot flight controller IDs"
commit-message: "chore(flightcontroller): Updated ArduPilot flight controller IDs"
body: |
This PR updates the ArduPilot flight controller IDs from the upstream ArduPilot repository.
delete-branch: true