jessica-mitchell is testing out GitHub Actions π #26
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Target Workflow | |
on: | |
workflow_dispatch: | |
repository_dispatch: | |
types: [Integration-with-Automation] | |
run-name: ${{ github.actor }} is testing out GitHub Actions π | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
NAME: ebrains-experimental | |
DISPLAY_NAME: "EBRAINS-experimental" | |
steps: | |
- name: Get NEST version | |
run: echo "NEST_VERSION=$(wget -q -O - 'https://gitlab.ebrains.eu/ri/tech-hub/platform/esd/ebrains-spack-builds/-/raw/master/spack.yaml?ref_type=heads&inline=false' | sed -rn 's/^\s.*nest@([0-9]\.[0-9]).*/\1/p')" >> $GITHUB_ENV | |
- name: Test environment variable | |
run: | | |
echo "The nest version in experimental is $NEST_VERSION" | |
- name: Check out current repo | |
uses: actions/checkout@v4 | |
- name: Create new branch | |
run: | | |
git checkout -B $NEST_VERSION | |
git push -u origin $NEST_VERSION | |
- name: Get rc tag | |
id: version_tag | |
run: | | |
# Create the branch/tag dynamically | |
# For example, NEST_VERSION = "3.8" and we expect "v3.8_rc1" | |
rc_number=1 # Adjust if needed | |
BRANCH_NAME="v${NEST_VERSION}_rc${rc_number}" | |
echo "Branch name is: $BRANCH_NAME" | |
echo "branch=$BRANCH_NAME" >> $GITHUB_OUTPUT | |
- name: Checkout nest-simulator repo | |
uses: actions/checkout@v4 | |
with: | |
repository: jessica-mitchell/nest-simulator | |
# for testing use known branch | |
# ref: refs/heads/jupytext | |
ref: ${{ steps.version_tag.outputs.branch }} # Use the dynamically created branch | |
token: ${{ secrets.API_TOKEN_GITHUB }} | |
path: nest-simulator # Directory to place the repository in | |
- name: Copy Python example files to current repo | |
run: | | |
# TODO ensure all necessary files are copied (consider non python files?) | |
# for testing make temp directory | |
mkdir temp_examples | |
# cp -r nest-simulator/pynest/examples/*.py temp_examples/ | |
rsync -aP --exclude '**.png' --exclude '**.gif' nest-simulator/pynest/examples temp_examples | |
# find nest-simulator/pynest/examples/ -iname "*.py" -exec cp --parents \{\} ./temp_examples \; | |
- name: "Install Python dependencies" | |
run: | | |
python -m pip install --upgrade pip setuptools | |
python -m pip install ipykernel jupytext | |
- name: "Convert to notebooks and set kernel" | |
run: | | |
jupytext --to notebook $(find temp_examples -iname "*.py") | |
python -m ipykernel install --user --name "$NAME" --display-name "$DISPLAY_NAME" | |
jupytext --set-kernel "$NAME" $(find temp_examples -iname "*.ipynb") | |
- name: Commit and push changes | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git add temp_examples/ | |
git commit -m "Add Python files from nest v${NEST_VERSION}_rc${rc_number}" | |
git push origin HEAD |