diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 15ea7bac77..af0e3a5bc3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,7 +7,33 @@ on: branches: ['main'] jobs: + changes: + runs-on: ubuntu-latest + permissions: + pull-requests: read + outputs: + needs_build: ${{ steps.filter.outputs.needs_build }} + templates: ${{ steps.filter.outputs.templates }} + steps: + - uses: dorny/paths-filter@v2 + id: filter + with: + filters: | + needs_build: + - 'packages/**' + - 'test/**' + - 'pnpm-lock.yaml' + - 'package.json' + templates: + - 'templates/**' + - name: Log all filter results + run: | + echo "needs_build: ${{ steps.filter.outputs.needs_build }}" + echo "templates: ${{ steps.filter.outputs.templates }}" + core-build: + needs: changes + if: ${{ needs.changes.outputs.needs_build == 'true' }} runs-on: ubuntu-latest steps: @@ -246,3 +272,34 @@ jobs: - name: Test ${{ matrix.pkg }} run: pnpm --filter ${{ matrix.pkg }} run test if: matrix.pkg != 'create-payload-app' # degit doesn't work within GitHub Actions + + templates: + needs: changes + if: ${{ needs.changes.outputs.templates == 'true' }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + template: [blank, website, ecommerce] + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 25 + + - name: Use Node.js 18 + uses: actions/setup-node@v3 + with: + node-version: 18 + + - name: Start MongoDB + uses: supercharge/mongodb-github-action@1.10.0 + with: + mongodb-version: 6.0 + + - name: Build Website + run: | + cd templates/${{ matrix.template }} + cp .env.example .env + yarn install + yarn build