ci: Add more PR trigger types for CI #15
Workflow file for this run
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: Monkey CI - PRs | |
| env: | |
| PNPM_VERSION: "10.33.0" | |
| NODE_VERSION: "24.15.0" | |
| RECAPTCHA_SITE_KEY: "6Lc-V8McAAAAAJ7s6LGNe7MBZnRiwbsbiWts87aj" | |
| permissions: | |
| contents: read | |
| on: | |
| pull_request: | |
| branches: [main] | |
| types: [opened, reopened, synchronize, labeled, ready_for_review] | |
| concurrency: | |
| group: group-${{ github.ref }}-${{ github.workflow }} | |
| cancel-in-progress: true | |
| jobs: | |
| pre-ci: | |
| name: pre-ci | |
| runs-on: ubuntu-latest | |
| outputs: | |
| should-build-be: ${{ steps.export-changes.outputs.should-build-be }} | |
| should-build-fe: ${{ steps.export-changes.outputs.should-build-fe }} | |
| should-build-pkg: ${{ steps.export-changes.outputs.should-build-pkg }} | |
| assets-or-styles: ${{ steps.export-changes.outputs.assets-or-styles }} | |
| steps: | |
| - name: Full checkout | |
| uses: actions/checkout@v4 | |
| - name: Detect changes | |
| uses: dorny/paths-filter@v4 | |
| id: filter | |
| with: | |
| filters: | | |
| assets-or-styles: | |
| - 'frontend/static/**/*' | |
| - '**/*.{scss,css}' | |
| be-src: | |
| - 'backend/**/*.{ts,js,json,lua,css,html}' | |
| - 'backend/package.json' | |
| fe-src: | |
| - 'frontend/**/*.{ts,scss,html}' | |
| - 'frontend/package.json' | |
| pkg-src: | |
| - 'packages/**/*' | |
| - name: Export changes | |
| id: export-changes | |
| run: | | |
| echo "should-build-pkg=${{ steps.filter.outputs.pkg-src }}" >> $GITHUB_OUTPUT | |
| echo "should-build-be=${{ steps.filter.outputs.be-src }}" >> $GITHUB_OUTPUT | |
| echo "should-build-fe=${{ steps.filter.outputs.fe-src }}" >> $GITHUB_OUTPUT | |
| echo "assets-or-styles=${{ steps.filter.outputs.assets-or-styles }}" >> $GITHUB_OUTPUT | |
| prime-cache: | |
| name: prime-cache | |
| runs-on: ubuntu-latest | |
| needs: [pre-ci] | |
| if: needs.pre-ci.outputs.should-build-be == 'true' || needs.pre-ci.outputs.should-build-fe == 'true' || needs.pre-ci.outputs.should-build-pkg == 'true' || needs.pre-ci.outputs.assets-or-styles == 'true' || contains(github.event.pull_request.labels.*.name, 'force-full-ci') | |
| steps: | |
| - name: Sparse checkout pnpm-lock | |
| uses: actions/checkout@v4 | |
| with: | |
| sparse-checkout: | | |
| pnpm-lock.yaml | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: ${{ env.PNPM_VERSION }} | |
| - name: Get pnpm store directory | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
| - name: Cache node modules | |
| id: cache-pnpm | |
| uses: actions/cache@v4 | |
| env: | |
| cache-name: node-modules | |
| with: | |
| path: ${{ env.STORE_PATH }} | |
| key: ${{ runner.os }}-${{ env.NODE_VERSION }}-build-${{ env.cache-name }}-${{ hashFiles('pnpm-lock.yaml') }} | |
| lookup-only: true | |
| - if: steps.cache-pnpm.outputs.cache-hit != 'true' || contains(github.event.pull_request.labels.*.name, 'refresh-ci-cache') | |
| name: Full checkout | |
| uses: actions/checkout@v4 | |
| - if: steps.cache-pnpm.outputs.cache-hit != 'true' || contains(github.event.pull_request.labels.*.name, 'refresh-ci-cache') | |
| name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| - if: steps.cache-pnpm.outputs.cache-hit != 'true' || contains(github.event.pull_request.labels.*.name, 'refresh-ci-cache') | |
| name: Install dependencies | |
| run: CI=true pnpm install --frozen-lockfile | |
| ci-be: | |
| name: ci-be | |
| needs: [pre-ci, prime-cache] | |
| runs-on: ubuntu-latest | |
| if: needs.pre-ci.outputs.should-build-be == 'true' || needs.pre-ci.outputs.should-build-pkg == 'true' || contains(github.event.pull_request.labels.*.name, 'force-full-ci') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| sparse-checkout: | | |
| backend | |
| packages | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: ${{ env.PNPM_VERSION }} | |
| - name: Get pnpm store directory | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
| - name: Cache node modules | |
| id: cache-pnpm | |
| uses: actions/cache@v4 | |
| env: | |
| cache-name: node-modules | |
| with: | |
| path: ${{ env.STORE_PATH }} | |
| key: ${{ runner.os }}-${{ env.NODE_VERSION }}-build-${{ env.cache-name }}-${{ hashFiles('pnpm-lock.yaml') }} | |
| - name: Install dependencies | |
| run: CI=true pnpm install --frozen-lockfile | |
| - name: Check lint | |
| run: npm run lint-fast-be && npm run lint-be | |
| - name: Build | |
| run: npm run build-be | |
| - name: Test | |
| run: npm run test-be | |
| ci-fe: | |
| name: ci-fe | |
| needs: [pre-ci, prime-cache] | |
| runs-on: ubuntu-latest | |
| if: needs.pre-ci.outputs.should-build-fe == 'true' || needs.pre-ci.outputs.should-build-pkg == 'true' || contains(github.event.pull_request.labels.*.name, 'force-full-ci') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| sparse-checkout: | | |
| frontend | |
| packages | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| - name: Create stub firebase config | |
| working-directory: ./frontend/src/ts/constants | |
| run: mv ./firebase-config-example.ts ./firebase-config.ts && cp ./firebase-config.ts ./firebase-config-live.ts | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: ${{ env.PNPM_VERSION }} | |
| - name: Get pnpm store directory | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
| - name: Cache node modules | |
| id: cache-pnpm | |
| uses: actions/cache@v4 | |
| env: | |
| cache-name: node-modules | |
| with: | |
| path: ${{ env.STORE_PATH }} | |
| key: ${{ runner.os }}-${{ env.NODE_VERSION }}-build-${{ env.cache-name }}-${{ hashFiles('pnpm-lock.yaml') }} | |
| - name: Install dependencies | |
| run: CI=true pnpm install --frozen-lockfile | |
| - name: Check lint | |
| run: npm run lint-fast-fe && npm run lint-fe | |
| - name: Build | |
| run: npm run build-fe | |
| - name: Test | |
| run: npm run test-fe | |
| ci-assets: | |
| name: ci-assets | |
| needs: [pre-ci, prime-cache] | |
| runs-on: ubuntu-latest | |
| if: needs.pre-ci.outputs.assets-or-styles == 'true' || contains(github.event.pull_request.labels.*.name, 'force-full-ci') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| sparse-checkout: | | |
| frontend | |
| packages | |
| - uses: dorny/paths-filter@v4 | |
| id: filter | |
| with: | |
| filters: | | |
| styles: | |
| - '**/*.{scss,css}' | |
| json: | |
| - 'frontend/static/**/*.json' | |
| languages: | |
| - 'frontend/static/languages/**' | |
| quotes: | |
| - 'frontend/static/quotes/**' | |
| others: | |
| - 'frontend/static/layouts/**' | |
| - 'frontend/static/themes/**' | |
| - 'frontend/static/webfonts/**' | |
| - 'frontend/static/challenges/**' | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: ${{ env.PNPM_VERSION }} | |
| - name: Get pnpm store directory | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
| - name: Cache node modules | |
| id: cache-pnpm | |
| uses: actions/cache@v4 | |
| env: | |
| cache-name: node-modules | |
| with: | |
| path: ${{ env.STORE_PATH }} | |
| key: ${{ runner.os }}-${{ env.NODE_VERSION }}-build-${{ env.cache-name }}-${{ hashFiles('pnpm-lock.yaml') }} | |
| - name: Install dependencies | |
| run: CI=true pnpm install --frozen-lockfile | |
| - name: Lint styles | |
| if: steps.filter.outputs.styles == 'true' || contains(github.event.pull_request.labels.*.name, 'force-full-ci') | |
| run: npm run lint-styles | |
| - name: Lint JSON | |
| if: steps.filter.outputs.json == 'true' || contains(github.event.pull_request.labels.*.name, 'force-full-ci') | |
| run: npm run lint-json-assets | |
| - name: Validate language assets | |
| if: steps.filter.outputs.languages == 'true' || contains(github.event.pull_request.labels.*.name, 'force-full-ci') | |
| run: npm run check-assets-languages | |
| - name: Validate quote assets | |
| if: steps.filter.outputs.quotes == 'true' || contains(github.event.pull_request.labels.*.name, 'force-full-ci') | |
| run: npm run check-assets-quotes | |
| - name: Validate other assets | |
| if: steps.filter.outputs.others == 'true' || contains(github.event.pull_request.labels.*.name, 'force-full-ci') | |
| run: npm run check-assets-others | |
| ci-pkg: | |
| name: ci-pkg | |
| needs: [pre-ci, prime-cache] | |
| runs-on: ubuntu-latest | |
| if: needs.pre-ci.outputs.should-build-pkg == 'true' || contains(github.event.pull_request.labels.*.name, 'force-full-ci') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| sparse-checkout: | | |
| packages | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: ${{ env.PNPM_VERSION }} | |
| - name: Get pnpm store directory | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
| - name: Cache node modules | |
| id: cache-pnpm | |
| uses: actions/cache@v4 | |
| env: | |
| cache-name: node-modules | |
| with: | |
| path: ${{ env.STORE_PATH }} | |
| key: ${{ runner.os }}-${{ env.NODE_VERSION }}-build-${{ env.cache-name }}-${{ hashFiles('pnpm-lock.yaml') }} | |
| - name: Install dependencies | |
| run: CI=true pnpm install --frozen-lockfile | |
| - name: Check lint | |
| run: npm run lint-fast-pkg && npm run lint-pkg | |
| - name: Build | |
| run: npm run build-pkg | |
| - name: Test | |
| run: npm run test-pkg |