Add description to moon.mod.json #2
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
| # Deploy examples to GitHub Pages | |
| name: Deploy to GitHub Pages | |
| on: | |
| push: | |
| branches: ["main"] | |
| workflow_dispatch: | |
| # 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. | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up MoonBit | |
| run: | | |
| curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash | |
| echo "$HOME/.moon/bin" >> $GITHUB_PATH | |
| - name: Install MoonBit dependencies | |
| run: | | |
| moon version --all | |
| moon update | |
| - name: Build examples | |
| working-directory: examples | |
| run: moon build --target js | |
| - name: Prepare deployment directory | |
| run: | | |
| mkdir -p _site | |
| # Copy canvas example | |
| mkdir -p _site/canvas | |
| cp examples/canvas/canvas.html _site/canvas/index.html | |
| cp examples/target/js/release/build/canvas/canvas.js _site/canvas/ | |
| # Copy counter example | |
| mkdir -p _site/counter | |
| cp examples/counter/counter.js.html _site/counter/index.html | |
| cp examples/target/js/release/build/counter/counter.js _site/counter/ | |
| # Create index page | |
| cat > _site/index.html << 'EOF' | |
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>MoonBit WebAPI Examples</title> | |
| <style> | |
| body { | |
| font-family: system-ui, -apple-system, sans-serif; | |
| max-width: 800px; | |
| margin: 0 auto; | |
| padding: 2rem; | |
| background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%); | |
| min-height: 100vh; | |
| color: #fff; | |
| } | |
| h1 { | |
| font-weight: 300; | |
| letter-spacing: 2px; | |
| } | |
| ul { | |
| list-style: none; | |
| padding: 0; | |
| } | |
| li { | |
| margin: 1rem 0; | |
| } | |
| a { | |
| color: #64b5f6; | |
| text-decoration: none; | |
| font-size: 1.2rem; | |
| } | |
| a:hover { | |
| text-decoration: underline; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <h1>🌙 MoonBit WebAPI Examples</h1> | |
| <ul> | |
| <li><a href="canvas/">🎨 Canvas Demo</a></li> | |
| <li><a href="counter/">🔢 Counter Demo</a></li> | |
| </ul> | |
| </body> | |
| </html> | |
| EOF | |
| - name: Fix script paths in HTML | |
| run: | | |
| # Update canvas HTML to use local path | |
| sed -i 's|../target/js/release/build/canvas/canvas.js|canvas.js|g' _site/canvas/index.html | |
| # Update counter HTML to use local path | |
| sed -i 's|../target/js/release/build/counter/counter.js|counter.js|g' _site/counter/index.html | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v5 | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: '_site' | |
| deploy: | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |