/ .github / workflows / update-chip-choices.yml
update-chip-choices.yml
 1  name: Update Chip Choices
 2  
 3  on:
 4      # Run on a schedule (daily at 2 AM UTC)
 5      schedule:
 6          - cron: "0 2 * * *"
 7      # Allow manual triggering
 8      workflow_dispatch:
 9      # Also run when the workflow file changes
10      push:
11          paths:
12              - ".github/workflows/update-chip-choices.yml"
13              - "scripts/update-chip-choices.py"
14  
15  jobs:
16      update-chips:
17          if: false
18          runs-on: ubuntu-latest
19          permissions:
20              contents: write
21              pull-requests: write
22  
23          steps:
24              - name: Checkout repository
25                uses: actions/checkout@v4
26                with:
27                    token: ${{ secrets.GITHUB_TOKEN }}
28                    fetch-depth: 0
29  
30              - name: Setup Python
31                uses: actions/setup-python@v5
32                with:
33                    python-version: "3.x"
34  
35              - name: Update chip choices
36                id: update
37                run: |
38                    python3 scripts/update-chip-choices.py
39                    echo "updated=true" >> $GITHUB_OUTPUT
40  
41              - name: Check for changes
42                id: git-check
43                run: |
44                    if [ -n "$(git status --porcelain cargo-generate.toml pre-script.rhai)" ]; then
45                      echo "changed=true" >> $GITHUB_OUTPUT
46                      echo "Chip choices and configurations have been updated"
47                      git diff cargo-generate.toml pre-script.rhai
48                    else
49                      echo "changed=false" >> $GITHUB_OUTPUT
50                      echo "No changes to chip choices or configurations"
51                    fi
52  
53              - name: Commit and push changes
54                if: steps.git-check.outputs.changed == 'true'
55                run: |
56                    git config --local user.email "action@github.com"
57                    git config --local user.name "GitHub Action"
58                    git add cargo-generate.toml pre-script.rhai
59                    git commit -m "chore: auto-update chip choices and configurations from stm32-data-generated
60  
61                    This commit was automatically generated by the update-chip-choices workflow.
62                    It updates:
63                    - Available chip choices in cargo-generate.toml
64                    - Target configurations in pre-script.rhai
65  
66                    Data sourced from embassy-rs/stm32-data-generated."
67                    git push
68  
69              - name: Create Pull Request
70                if: steps.git-check.outputs.changed == 'true' && github.event_name == 'schedule'
71                uses: peter-evans/create-pull-request@v5
72                with:
73                    token: ${{ secrets.GITHUB_TOKEN }}
74                    commit-message: "chore: auto-update chip choices and configurations from stm32-data-generated"
75                    title: "chore: Auto-update chip choices and configurations from stm32-data-generated"
76                    body: |
77                        This PR was automatically created by the update-chip-choices workflow.
78  
79                        It updates the available chip choices and configurations based on the
80                        latest data from [embassy-rs/stm32-data-generated](https://github.com/embassy-rs/stm32-data-generated).
81  
82                        ## Changes
83                        - Updated chip choices list in `cargo-generate.toml`
84                        - Updated STM32 configurations in `pre-script.rhai` (flash/RAM layout, Rust targets)
85                        - Added new STM32 chips from stm32-data-generated
86                        - Preserved existing non-STM32 chips (nrf, rp, esp)
87  
88                        ## What's Updated
89                        The script fetches metadata for 20 representative STM32 chips from different families and generates
90                        their configurations (memory layout, Rust target triple, probe chip name). Other STM32 chips use
91                        intelligent family-based defaults.
92  
93                        ## Review
94                        Please review the changes and merge if they look correct.
95                    branch: auto-update-chip-choices
96                    delete-branch: true