Deploying Your Simulation to GitHub Pages ======================================== You can deploy your ``brian2wasm`` simulation to `GitHub Pages `_, enabling others to view and interact with it directly in a web browser without any local installation. Prerequisites ------------- Ensure your repository includes: - Your ``brian2wasm`` simulation script (e.g., ``your_script.py``). - The ``pyproject.toml`` file from the ``brian2wasm`` repository. - A folder structure like this: .. code-block:: text 📁 root folder ├─ 📁 .github │ └─ 📁 workflows │ └─ 📄 deploy.yml ├─ 📁 brian2wasm ├─ 📁 examples ├─ 📄 your_script.py └─ 📄 pyproject.toml .. note:: Ensure all required files, including the simulation script and its corresponding HTML file (if customized), are committed to your repository. Setup Instructions ------------------ Follow these steps to deploy your simulation to GitHub Pages: 1. **Create the GitHub Actions Workflow** Create a file named ``.github/workflows/deploy.yml`` in your repository with the following content: .. code-block:: yaml name: Deploy Brian2WASM Simulation to GitHub Pages on: push: branches: [ main ] paths: - ".github/workflows/deploy.yml" - "**.py" - "**.html" permissions: contents: write jobs: build-and-deploy: runs-on: ubuntu-latest env: SCRIPT: path/to/your/script.py # Replace with your script path steps: - name: Checkout code uses: actions/checkout@v4 - name: Install Pixi uses: prefix-dev/setup-pixi@v0.8.0 with: cache: false - name: Install dependencies run: pixi install --locked - name: Run setup run: pixi run setup - name: Derive folder paths id: derive run: | # Remove .py extension FOLDER_PATH="${SCRIPT%.py}" # Get the last folder name (e.g., ornstein_uhlenbeck) FOLDER_NAME=$(basename "$FOLDER_PATH") echo "FOLDER_PATH=$FOLDER_PATH" >> $GITHUB_ENV echo "FOLDER_NAME=$FOLDER_NAME" >> $GITHUB_ENV - name: Generate simulation files run: | python -m brian2wasm $SCRIPT --no-server shell: pixi run bash -e {0} - name: Deploy to gh-pages run: | git fetch origin gh-pages || true git checkout gh-pages || git checkout --orphan gh-pages rm -rf $FOLDER_NAME mkdir -p $FOLDER_NAME cp $FOLDER_PATH/brian.js \ $FOLDER_PATH/index.html \ $FOLDER_PATH/wasm_module.js \ $FOLDER_PATH/wasm_module.wasm \ $FOLDER_PATH/worker.js \ $FOLDER_NAME/ || true cat > index.html < ${GITHUB_ACTOR}'s Brian2WASM Simulations

${GITHUB_ACTOR}'s Brian2WASM Simulations