TMP - add a few more notebooks #29
This file contains hidden or 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
| # NOTE THAT in addition to this file, you need to check on github.com | |
| # - enable github pages (select deploy from a branch) | |
| # - go to the Settings -> Environments tab | |
| # then select the 'github-pages' environment | |
| # and make sure the branch of interest (here main) is allowed in the 'Branch protection rules' area | |
| name: Deploy MyST to GitHub Pages | |
| on: | |
| # Allows manual trigger | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| # the following sets permissions of the GITHUB_TOKEN | |
| # to allow deployment to GitHub Pages | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | |
| # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| # this is no longer needed as we serve from info-mines.paris | |
| # required for MyST | |
| # env: | |
| # # `BASE_URL` determines the website is served from, including CSS & JS assets | |
| # # You may need to change this to `BASE_URL: ''` | |
| # BASE_URL: /${{ github.event.repository.name }} | |
| jobs: | |
| build-and-deploy: | |
| runs-on: self-hosted | |
| container: | |
| image: ghcr.io/prefix-dev/pixi:latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| clean: true | |
| - name: Setup dependencies | |
| run: | | |
| pixi install | |
| - name: Install MyST Markdown | |
| run: | | |
| pixi run install-myst | |
| - name: Install utils | |
| run: | | |
| # apt update && apt install -y net-tools iproute2 metcat-openbsd curl procps | |
| apt update && apt install -y net-tools | |
| - name: Start Background Monitor | |
| run: | | |
| cat << 'EOF' > monitor.sh | |
| echo "Starting monitor..." | |
| while true; do | |
| pids=$(pgrep -f ipykernel || true) | |
| if [ -z "$pids" ]; then | |
| echo "$(date +%H:%M:%S) === No ipykernel found" | |
| else | |
| echo "$(date +%H:%M:%S) === Found PIDs: $pids" | |
| ps -p $pids -o pid,ppid,cmd,%mem,%cpu | |
| # Check if they are listening on any ports | |
| netstat -tunlp | grep -E "python|jupyter" || echo "No ports open yet" | |
| fi | |
| sleep 1 | |
| done | |
| EOF | |
| chmod +x monitor.sh | |
| # Run in background and redirect output to a file we can read later | |
| ./monitor.sh > monitor.log 2>&1 & | |
| echo $! > monitor.pid | |
| echo "Monitor started with PID $(cat monitor.pid)" | |
| - name: Build HTML Assets | |
| run: | | |
| export PYTHONPATH=$(pwd)/modules | |
| pixi run myst-build | |
| - name: Finalize and Show Logs | |
| if: always() | |
| run: | | |
| echo "--- DEBUG LOGS FROM MONITOR ---" | |
| if [ -f monitor.log ]; then cat monitor.log; fi | |
| if [ -f monitor.pid ]; then kill $(cat monitor.pid) || true; fi | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v3 | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: './_build/html' | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} |