concept-collection / numbl-project-example
Initial commit: numbl project example for GitHub Pages
Jeremy Magland <jmagland@flatironinstitute.org> committed commit 33de3180da55 Browse files
6 changed files+91−0
.github/workflows/deploy.ymladded+40−0View file
@@ -0,0 +1,40 @@
1+name: Deploy numbl project to GitHub Pages
2+
3+# Bundles this numbl project with the browser IDE and publishes it to GitHub
4+# Pages on every push to main.
5+#
6+# One-time setup: Settings → Pages → "Build and deployment" → Source →
7+# "GitHub Actions".
8+
9+on:
10+ push:
11+ branches: [main]
12+ workflow_dispatch:
13+
14+permissions:
15+ contents: read
16+ pages: write
17+ id-token: write
18+
19+concurrency:
20+ group: pages
21+ cancel-in-progress: false
22+
23+jobs:
24+ build:
25+ runs-on: ubuntu-latest
26+ steps:
27+ - uses: actions/checkout@v4
28+ - uses: flatironinstitute/numbl/.github/actions/build-site@main
29+ with:
30+ project-dir: .
31+
32+ deploy:
33+ needs: build
34+ runs-on: ubuntu-latest
35+ environment:
36+ name: github-pages
37+ url: ${{ steps.deployment.outputs.page_url }}
38+ steps:
39+ - id: deployment
40+ uses: actions/deploy-pages@v4
.gitignoreadded+4−0View file
@@ -0,0 +1,4 @@
1+# Local output from `numbl build-site`
2+/_site/
3+/dist/
4+node_modules/
README.mdadded+26−0View file
@@ -0,0 +1,26 @@
1+# numbl project example
2+
3+A tiny example [numbl](https://numbl.org) project deployed to **GitHub Pages**.
4+Everything runs in your browser — pick a script in the panel on the left and
5+click **Run**. You can edit any file too; changes stay in memory for your
6+session.
7+
8+## Files
9+
10+- [`main.m`](main.m) — prints a couple of values and draws a plot.
11+- [`waves.m`](waves.m) — a small helper function used by `main.m`.
12+
13+```matlab
14+x = linspace(0, 4*pi, 400);
15+plot(x, exp(-x/10) .* sin(x));
16+title('damped sine');
17+```
18+
19+## How it's deployed
20+
21+On every push to `main`, the workflow in
22+[`.github/workflows/deploy.yml`](.github/workflows/deploy.yml) bundles these
23+files with the numbl browser IDE and publishes the result to GitHub Pages — no
24+server, nothing to build by hand.
25+
26+Edit `numbl-project.json` to change the title or which file opens first.
main.madded+13−0View file
@@ -0,0 +1,13 @@
1+% main.m — click "Run" to execute this in your browser.
2+
3+x = linspace(0, 4*pi, 400);
4+y = waves(x);
5+
6+fprintf('peak value: %.4f\n', max(y));
7+fprintf('zero crossings: %d\n', sum(abs(diff(sign(y))) > 0));
8+
9+plot(x, y);
10+title('damped sine: e^{-x/10} sin(x)');
11+xlabel('x');
12+ylabel('y');
13+grid on;
numbl-project.jsonadded+4−0View file
@@ -0,0 +1,4 @@
1+{
2+ "title": "numbl project example",
3+ "entry": "README.md"
4+}
waves.madded+4−0View file
@@ -0,0 +1,4 @@
1+function y = waves(x)
2+% WAVES A damped sine wave, y = exp(-x/10) .* sin(x).
3+ y = exp(-x / 10) .* sin(x);
4+end