|
| 1 | +name: Check for changes in NP json files |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: '0 0 * * 2' # Every Tuesday at 00: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 repository |
| 29 | + run: | |
| 30 | + git clone https://github.com/spikeinterface/probeinterface ./probeinterface |
| 31 | +
|
| 32 | + - name: Install probeinterface and matplotlib |
| 33 | + run: pip install ./probeinterface matplotlib |
| 34 | + |
| 35 | + - name: Generate full NP library |
| 36 | + run: | |
| 37 | + cd scripts/ |
| 38 | + python ../probeinterface/resources/generate_neuropixels_library.py |
| 39 | +
|
| 40 | + # Check for any new probes |
| 41 | + - name: Run local script |
| 42 | + run: | |
| 43 | + rsync -av --include='*/' --include='*.json' --exclude='*' scripts/neuropixels_library_generated/ imec/ |
| 44 | + rm -r scripts/neuropixels_library_generated/ |
| 45 | + rm -r ./probeinterface |
| 46 | +
|
| 47 | + - name: Commit changes if any |
| 48 | + id: commit |
| 49 | + run: | |
| 50 | + git config --local user.email "[email protected]" |
| 51 | + git config --local user.name "GitHub Action" |
| 52 | +
|
| 53 | + git add imec/* |
| 54 | +
|
| 55 | + # Only commit if there are changes |
| 56 | + if git diff --staged --quiet; then |
| 57 | + echo "No changes to commit" |
| 58 | + echo "changes=false" >> $GITHUB_OUTPUT |
| 59 | + else |
| 60 | + git commit -m "Update json files for NP probes" |
| 61 | + echo "changes=true" >> $GITHUB_OUTPUT |
| 62 | + fi |
| 63 | +
|
| 64 | + - name: Create pull request to add probes |
| 65 | + if: steps.commit.outputs.changes == 'true' |
| 66 | + uses: peter-evans/create-pull-request@v7 |
| 67 | + with: |
| 68 | + title: "Update Neuropixels json files" |
| 69 | + 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." |
| 70 | + branch-suffix: short-commit-hash |
| 71 | + base: "main" |
0 commit comments