|
| 1 | +name: Generate Cambridge Neurotech library |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: '0 1 * * 1' # Every Monday at 01:00 UTC |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +# Grant permissions for the job to write to contents (push) and create PRs. |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + pull-requests: write |
| 12 | + |
| 13 | +jobs: |
| 14 | + build-and-pr: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + |
| 18 | + - name: Check out local repository |
| 19 | + uses: actions/checkout@v4 |
| 20 | + |
| 21 | + # Set up a Python environment |
| 22 | + - name: Set up Python |
| 23 | + uses: actions/setup-python@v5 |
| 24 | + with: |
| 25 | + python-version: '3.10' |
| 26 | + |
| 27 | + # Clone dev version of probeinterface |
| 28 | + - name: Clone external repositories |
| 29 | + run: | |
| 30 | + # probeinterface |
| 31 | + git clone https://github.com/spikeinterface/probeinterface ./probeinterface |
| 32 | +
|
| 33 | + # cambridge neurotech probe maps |
| 34 | + git clone https://github.com/cambridge-neurotech/probe_maps.git ./probe_maps |
| 35 | +
|
| 36 | + - name: Install probeinterface and matplotlib |
| 37 | + run: pip install ./probeinterface matplotlib |
| 38 | + |
| 39 | + - name: Generate full cambridge library and check for changes |
| 40 | + run: | |
| 41 | + cd scripts/ |
| 42 | + python ../probeinterface/resources/generate_cambridgeneurotech_library.py ../probe_maps/ ./cambridge_library_generated/ |
| 43 | +
|
| 44 | + # check for json changes (except probeinterface version) |
| 45 | + python check_for_json_changes_in_probes.py ../cambridgeneurotech/ ./cambridge_library_generated/ |
| 46 | + # clean up |
| 47 | + rm -r cambridge_library_generated/ |
| 48 | + cd .. |
| 49 | + rm -r ./probeinterface |
| 50 | +
|
| 51 | + - name: Commit changes if any |
| 52 | + id: commit |
| 53 | + run: | |
| 54 | + git config --local user.email "action@github.com" |
| 55 | + git config --local user.name "GitHub Action" |
| 56 | +
|
| 57 | + git add cambridgeneurotech/* |
| 58 | +
|
| 59 | + # Only commit if there are changes |
| 60 | + if git diff --staged --quiet; then |
| 61 | + echo "No changes to commit" |
| 62 | + echo "changes=false" >> $GITHUB_OUTPUT |
| 63 | + else |
| 64 | + git commit -m "Update json files for NP probes" |
| 65 | + echo "changes=true" >> $GITHUB_OUTPUT |
| 66 | + fi |
| 67 | +
|
| 68 | + - name: Create pull request to add probes |
| 69 | + if: steps.commit.outputs.changes == 'true' |
| 70 | + uses: peter-evans/create-pull-request@v7 |
| 71 | + with: |
| 72 | + title: "Update Cambridge Neurotech json files" |
| 73 | + body: "This PR updates the Neuropixel probes in probeinterace library, based on new data from the ProbeTable repository or because of a new ProbeInterface release." |
| 74 | + branch-suffix: short-commit-hash |
| 75 | + base: "main" |
0 commit comments