diff --git a/.github/workflows/update_flightcontroller_ids.yml b/.github/workflows/update_flightcontroller_ids.yml new file mode 100644 index 0000000..68dea85 --- /dev/null +++ b/.github/workflows/update_flightcontroller_ids.yml @@ -0,0 +1,51 @@ +name: Update Flight Controller IDs + +on: + workflow_dispatch: + schedule: + - cron: '30 1 * * 3' # Every Wednesday at 1:30 AM + +jobs: + update-ids: + runs-on: ubuntu-latest + + steps: + - name: Checkout MethodicConfigurator + uses: actions/checkout@v4 + + - name: Checkout ArduPilot + uses: actions/checkout@v4 + with: + repository: ArduPilot/ardupilot + path: ../ardupilot + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + + - name: Update flight controller IDs + run: python update_flight_controller_ids.py + + - name: Commit changes + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git config user.email "github-actions[bot]@users.noreply.github.com" + git config user.name "github-actions[bot]" + git add ardupilot_methodic_configurator/middleware_fc_ids.py + if [ -n "$(git status --porcelain)" ]; then + CHANGED_LINES=$(git diff --staged | grep -E "^[\+\-]" | wc -l) + if [ $CHANGED_LINES -gt 3 ]; then + git commit -m "CHORE: Updated flight controller IDs [skip ci]" + git push + else + echo "Not enough changes to commit (only $CHANGED_LINES lines changed)" + fi + else + echo "No changes to commit" + fi