Repository navigation
Add GH action #1
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: Build and Deploy to GitHub Pages | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: 'recursive' | |
| - name: Cache apt packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: /var/cache/apt/archives | |
| key: ${{ runner.os }}-apt-cache-${{ hashFiles('.github/workflows/build.yml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-apt-cache- | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libusb-1.0-0-dev make autoconf automake libtool | |
| - name: Setup mise | |
| uses: jdx/mise-action@v2 | |
| - name: Get emsdk version | |
| id: emsdk_version | |
| run: echo "version=$(grep emsdk .mise.toml | cut -d'=' -f2 | tr -d ' ' | tr -d "\'")" >> $GITHUB_OUTPUT | |
| - name: Cache yarn cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: .yarn/cache | |
| key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-yarn- | |
| - name: Cache emsdk | |
| id: cache-emsdk | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.MISE_INSTALL_DIR }}/emsdk/${{ steps.emsdk_version.outputs.version }} | |
| key: ${{ runner.os }}-emsdk-${{ steps.emsdk_version.outputs.version }} | |
| - name: Install emsdk | |
| if: steps.cache-emsdk.outputs.cache-hit != 'true' | |
| run: emsdk install ${{ steps.emsdk_version.outputs.version }} | |
| - name: Activate emsdk | |
| run: source "$(mise where emsdk)/emsdk_env.sh" | |
| - name: Install dependencies and build | |
| run: make dist | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: './dist' | |
| deploy: | |
| needs: build | |
| if: github.ref == 'refs/heads/main' | |
| permissions: | |
| pages: write | |
| id-token: write | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |