Skip to content

Commit 8d1c804

Browse files
committed
initial action
1 parent bf6bc78 commit 8d1c804

2 files changed

Lines changed: 109 additions & 0 deletions

File tree

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Clone, Run Scripts, and Create PR
2+
3+
4+
on:
5+
schedule:
6+
- cron: '1 0 * * 1' # Every Monday at 00:00 UTC
7+
workflow_dispatch:
8+
9+
# Grant permissions for the job to write to contents (push) and create PRs.
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
14+
jobs:
15+
build-and-pr:
16+
runs-on: ubuntu-latest
17+
steps:
18+
# Step 1: Check out the code in your current (local) repository
19+
# We use a Personal Access Token (PAT) so the action has permission
20+
# to push a new branch and open a pull request.
21+
- name: Check out local repository
22+
uses: actions/checkout@v4
23+
# with:
24+
# # --- USER ACTION REQUIRED ---
25+
# # You MUST create a repository secret named GH_PAT.
26+
# # Go to Settings > Secrets and Variables > Actions > New repository secret
27+
# # The token needs the 'repo' (or 'public_repo') and 'workflow' scopes.
28+
# token: ${{ secrets.GH_PAT }}
29+
30+
# Step 2: Set up a Python environment
31+
- name: Set up Python
32+
uses: actions/setup-python@v5
33+
with:
34+
python-version: '3.10' # Or your preferred version
35+
cache: 'pip' # Caches dependencies to speed up future runs
36+
37+
# --- (Optional) ---
38+
# If your local script needs libraries, uncomment this step
39+
- name: Install local dependencies
40+
run: pip install probeinterface
41+
42+
# Step 3: Clone the *other* repository into a subfolder named './other-repo'
43+
- name: Clone external repository
44+
run: |
45+
# --- USER ACTION REQUIRED ---
46+
# Replace this URL with the repository you want to clone.
47+
# If it's a private repo, your GH_PAT must have access.
48+
git clone https://github.com/spikeinterface/probeinterface ./probeinterface
49+
50+
# --- (Optional) ---
51+
# If the external script needs libraries, uncomment this step
52+
# - name: Install external repo dependencies
53+
# run: pip install -r ./other-repo/requirements.txt
54+
55+
# Step 4: Run the Python script from the *external* repository
56+
- name: Run external script
57+
run: |
58+
# --- USER ACTION REQUIRED ---
59+
# Replace this path with the correct path to the script
60+
# in the repository you just cloned.
61+
cd tools/
62+
python ../../probeinterface/resources/generate_neuropixels_library.py
63+
64+
# Step 5: Run the Python script from your *local* repository
65+
# This is the script that should modify the files you want to PR.
66+
- name: Run local script
67+
run: |
68+
# --- USER ACTION REQUIRED ---
69+
# Replace this path with the correct path to your local script
70+
python check_for_new_NP_probes.py
71+
rm -r neuropixels_library_generated/
72+
cd ..
73+
74+
- name: Commit changes if any
75+
id: commit
76+
run: |
77+
git config --local user.email "action@github.com"
78+
git config --local user.name "GitHub Action"
79+
80+
git add imec/*
81+
82+
# Only commit if there are changes
83+
if git diff --staged --quiet; then
84+
echo "No changes to commit"
85+
echo "changes=false" >> $GITHUB_OUTPUT
86+
else
87+
git commit -m "Update neuropixels_probe_features from ProbeTable"
88+
echo "changes=true" >> $GITHUB_OUTPUT
89+
fi
90+
91+
- name: Update imec library with new probes
92+
if: steps.commit.outputs.changes == 'true'
93+
uses: peter-evans/create-pull-request@v7
94+
with:
95+
title: "Update library with new Neuropixels probes"
96+
body: "This PR updates the probeinterace library with new Neuropixel probes, auto-generated file from the ProbeTable repository."
97+
branch-suffix: short-commit-hash
98+
base: "main"

scripts/check_for_new_NP_probes.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from pathlib import Path
2+
import shutil
3+
4+
old_dir = Path('../imec')
5+
new_dir = Path('../../probeinterface/resources/test_np_lib')
6+
7+
existing_probes = list(probe_path.name for probe_path in old_dir.iterdir())
8+
9+
for temp_probe_path in new_dir.iterdir():
10+
if temp_probe_path.name not in existing_probes:
11+
shutil.copytree(f"{temp_probe_path}", f"../imec/{temp_probe_path.name}")

0 commit comments

Comments
 (0)