Consolidate CI workflows and add test gating #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: CI & Deploy | |
| on: | |
| push: | |
| branches: [main] | |
| tags: ['v*'] | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| jobs: | |
| build-and-test: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'pnpm' | |
| - name: Install root dependencies | |
| run: pnpm install | |
| - name: Build library | |
| run: pnpm run build | |
| - name: Run unit tests | |
| run: pnpm run test | |
| - name: Install site dependencies | |
| working-directory: ./site | |
| run: pnpm install | |
| - name: Lint site | |
| working-directory: ./site | |
| run: pnpm run lint | |
| - name: Build site | |
| working-directory: ./site | |
| run: pnpm run build | |
| - name: Add CNAME | |
| run: echo "prms.rbw.sh" > docs/CNAME | |
| - name: Create 404.html for SPA routing | |
| run: cp docs/index.html docs/404.html | |
| - name: Install Playwright browsers | |
| working-directory: ./site | |
| run: pnpm exec playwright install --with-deps chromium | |
| - name: Run E2E tests | |
| working-directory: ./site | |
| run: pnpm run test | |
| - name: Upload test report | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: playwright-report | |
| path: site/playwright-report/ | |
| retention-days: 7 | |
| - name: Setup Pages | |
| if: github.ref == 'refs/heads/main' | |
| uses: actions/configure-pages@v5 | |
| - name: Upload Pages artifact | |
| if: github.ref == 'refs/heads/main' | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: ./docs | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: build-and-test | |
| if: github.ref == 'refs/heads/main' | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| build-dist: | |
| needs: build-and-test | |
| if: github.ref == 'refs/heads/main' | |
| uses: runsascoded/npm-dist/.github/workflows/build-dist.yml@v1 | |
| release: | |
| needs: build-and-test | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| uses: runsascoded/pnpm-release/.github/workflows/release.yml@v1 | |
| secrets: | |
| npm_token: ${{ secrets.NPM_TOKEN }} |