ci: upgrade web #9
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
| name: Web Build | |
| on: | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| toolchain: 1.74.0 | |
| - name: Install wasi-vfs | |
| env: | |
| WASI_VFS_VERSION: 0.5.4 | |
| run: | | |
| curl -LO "https://github.com/kateinoigakukun/wasi-vfs/releases/download/v${WASI_VFS_VERSION}/wasi-vfs-cli-x86_64-unknown-linux-gnu.zip" | |
| unzip wasi-vfs-cli-x86_64-unknown-linux-gnu.zip | |
| mv wasi-vfs /usr/local/bin/wasi-vfs | |
| - uses: ruby/setup-ruby@v1 | |
| env: | |
| BUNDLE_GEMFILE: web/Gemfile | |
| with: | |
| ruby-version: 3.3 | |
| bundler-cache: true | |
| - name: Setup yarn | |
| run: npm install -g yarn | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: yarn | |
| cache-dependency-path: 'web/yarn.lock' | |
| - name: Cache ruby.wasm artefacts | |
| id: cache-ruby-wasm | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| web/build | |
| web/rubies | |
| key: ${{ runner.os }}-v1-ruby-wasm | |
| - name: Build ruby-warrior-web.wasm | |
| working-directory: ./web | |
| run: | | |
| bundle exec rbwasm build -o ruby-web.wasm | |
| wasi-vfs pack ruby-web.wasm \ | |
| --dir ./src::/app \ | |
| --dir ../bin::/app/bin \ | |
| --dir ../lib::/app/lib \ | |
| --dir ../templates::/app/templates \ | |
| --dir ../towers::/app/towers \ | |
| -o src/ruby-warrior-web.wasm | |
| - name: Build web app | |
| working-directory: ./web | |
| run: | | |
| yarn install | |
| yarn build | |
| - name: Push to Github Pages | |
| if: github.ref == 'refs/heads/master' || github.event_name == 'workflow_dispatch' | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: './web/dist' | |
| deploy: | |
| needs: build | |
| if: github.ref == 'refs/heads/master' || github.event_name == 'workflow_dispatch' | |
| # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| # Allow one concurrent deployment | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: true | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| uses: actions/deploy-pages@v4 |