diff --git a/.github/workflows/MERGE_MASTER.yml b/.github/workflows/MERGE_MASTER.yml index 91008f2..76192aa 100644 --- a/.github/workflows/MERGE_MASTER.yml +++ b/.github/workflows/MERGE_MASTER.yml @@ -6,8 +6,11 @@ on: push: branches: - master - schedule: - - cron: '0 5 * * *' + +concurrency: + group: ${{ github.head_ref }} + cancel-in-progress: true + env: DIRECT_DATABASE_URL: ${{secrets.DIRECT_DATABASE_URL}} DATABASE_URL: ${{secrets.DATABASE_URL}} @@ -18,7 +21,6 @@ env: ENVIRONMENT: ${{secrets.ENVIRONMENT}} CLOUDFLARE_ACCOUNT_ID: ${{secrets.CLOUDFLARE_ACCOUNT_ID}} CLOUDFLARE_API_TOKEN: ${{secrets.CLOUDFLARE_API_TOKEN}} - jobs: INSTALL: name: Install Dependencies @@ -27,51 +29,260 @@ jobs: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v3 with: - version: 9.1.1 + version: 9.12.1 - uses: actions/setup-node@v3 with: - node-version: '20' + node-version: '22.9.0' - uses: actions/cache@v3 id: cache-pnpm with: path: ./node_modules - key: ${{ runner.os }}-${{ hashFiles('./pnpm-lock.yaml', './prisma/dev.schema.prisma', './prisma/prod.schema.prisma') }} + key: ${{ runner.os }}-${{ hashFiles('./pnpm-lock.yaml', '/.npmrc') }} - name: Install if: steps.cache-pnpm.outputs.cache-hit != 'true' run: | pnpm i --frozen-lockfile - pnpm prisma:gen:ci - PUBLISH: - name: Publish to Production - environment: PRODUCTION + pnpm sync + LINT: + name: Lint runs-on: ubuntu-latest needs: INSTALL steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v3 with: - version: 9.1.1 + version: 9.12.1 + - uses: actions/setup-node@v3 + with: + node-version: '22.9.0' - uses: actions/cache@v3 with: path: ./node_modules - key: ${{ runner.os }}-${{ hashFiles('./pnpm-lock.yaml', './prisma/dev.schema.prisma', './prisma/prod.schema.prisma') }} + key: ${{ runner.os }}-${{ hashFiles('./pnpm-lock.yaml', '/.npmrc') }} + - name: Install Module Packages + run: | + pnpm i --frozen-lockfile + pnpm sync + - name: Lint + run: | + pnpm lint + VERIFY: + name: Verify + runs-on: ubuntu-latest + needs: INSTALL + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v3 + with: + version: 9.12.1 + - uses: actions/setup-node@v3 + with: + node-version: '22.9.0' + - uses: actions/cache@v3 + with: + path: ./node_modules + key: ${{ runner.os }}-${{ hashFiles('./pnpm-lock.yaml', '/.npmrc') }} + - name: Install Module Packages + run: | + pnpm i --frozen-lockfile + pnpm sync + - name: Check + run: | + pnpm check + UNIT_TEST: + name: Unit Tests + runs-on: ubuntu-latest + needs: INSTALL + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v3 + with: + version: 9.12.1 + - uses: actions/setup-node@v3 + with: + node-version: '22.9.0' + - uses: actions/cache@v3 + with: + path: ./node_modules + key: ${{ runner.os }}-${{ hashFiles('./pnpm-lock.yaml', '/.npmrc') }} + - name: Install Module Packages + run: | + pnpm i --frozen-lockfile + pnpm sync + - name: Unit Test + run: | + pnpm test + + ################ PUBLISH ################# + PUBLISH_WEBAPP: + name: Publish WebApp + environment: PREVIEW + runs-on: ubuntu-latest + needs: [INSTALL, LINT, VERIFY, UNIT_TEST] + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v3 + with: + version: 9.12.1 + - uses: actions/setup-node@v3 + with: + node-version: '22.9.0' + - uses: actions/cache@v3 + with: + path: ./node_modules + key: ${{ runner.os }}-${{ hashFiles('./pnpm-lock.yaml', '/.npmrc') }} + - name: Install Module Packages + run: | + pnpm i --frozen-lockfile + pnpm sync - name: Build env: IS_CI: false run: | - pnpm build:prod - - name: Publish to Cloudflare Pages + pnpm turbo @cloudkit/web#build + - name: Publish uses: cloudflare/pages-action@v1 with: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} projectName: cloudkit + workingDirectory: ./apps/web/ directory: ./.svelte-kit/cloudflare # Optional: Enable this if you want to have GitHub Deployments triggered + gitHubToken: ${{ secrets.GITHUB_TOKEN }} # Optional: Switch what branch you are publishing to. # By default this will be the branch which triggered this workflow - # branch: master + branch: ${{ github.head_ref }} # Optional: Change the working directory - # workingDirectory: my-site # Optional: Change the Wrangler version, allows you to point to a specific version or a tag such as `beta` wranglerVersion: '3' + PUBLISH_STORYBOOK: + name: Publish Storybook + environment: PREVIEW + runs-on: ubuntu-latest + needs: [INSTALL, LINT, VERIFY, UNIT_TEST] + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v3 + with: + version: 9.12.1 + - uses: actions/setup-node@v3 + with: + node-version: '22.9.0' + - uses: actions/cache@v3 + with: + path: ./node_modules + key: ${{ runner.os }}-${{ hashFiles('./pnpm-lock.yaml', '/.npmrc') }} + - name: Install Module Packages + run: | + pnpm i --frozen-lockfile + pnpm sync + - name: Build + env: + IS_CI: false + run: | + pnpm turbo run @cloudkit/styleguide#build + - name: Publish + uses: cloudflare/pages-action@v1 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + projectName: cloudkit-styleguide + workingDirectory: ./apps/styleguide/ + directory: ./storybook-static + # Optional: Enable this if you want to have GitHub Deployments triggered + gitHubToken: ${{ secrets.GITHUB_TOKEN }} + # Optional: Switch what branch you are publishing to. + # By default this will be the branch which triggered this workflow + branch: ${{ github.head_ref }} + # Optional: Change the working directory + # Optional: Change the Wrangler version, allows you to point to a specific version or a tag such as `beta` + wranglerVersion: '3' + + PUBLISH_SWAGGER: + name: Publish Swagger UI + environment: PREVIEW + runs-on: ubuntu-latest + needs: [INSTALL, LINT, VERIFY, UNIT_TEST] + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v3 + with: + version: 9.12.1 + - uses: actions/setup-node@v3 + with: + node-version: '22.9.0' + - uses: actions/cache@v3 + with: + path: ./node_modules + key: ${{ runner.os }}-${{ hashFiles('./pnpm-lock.yaml', '/.npmrc') }} + - name: Install Module Packages + run: | + pnpm i --frozen-lockfile + pnpm sync + - name: Build + env: + IS_CI: false + run: | + pnpm turbo run @cloudkit/swagger-ui#build + - name: Publish + uses: cloudflare/pages-action@v1 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + projectName: cloudkit-api + workingDirectory: ./apps/swagger-ui/ + directory: ./.svelte-kit/cloudflare + # Optional: Enable this if you want to have GitHub Deployments triggered + gitHubToken: ${{ secrets.GITHUB_TOKEN }} + # Optional: Switch what branch you are publishing to. + # By default this will be the branch which triggered this workflow + branch: ${{ github.head_ref }} + # Optional: Change the working directory + # Optional: Change the Wrangler version, allows you to point to a specific version or a tag such as `beta` + wranglerVersion: '3' + + + # Disable until I can figure out a way to deal with the flaky tests + # E2E_TEST: + # name: Run E2E Tests + # needs: [INSTALL] + # runs-on: ubuntu-latest + # steps: + # - name: Setup FFmpeg + # uses: AnimMouse/setup-ffmpeg@v1 + # - uses: actions/checkout@v4 + # - name: Set up Services + # run: | + # sudo docker-compose up -d + # - uses: pnpm/action-setup@v3 + # with: + # version: 9.12.1 + # - uses: actions/setup-node@v3 + # with: + # node-version: '22.9.0' + # cache: 'pnpm' + # - uses: actions/cache@v3 + # with: + # path: ./node_modules + # key: ${{ runner.os }}-${{ hashFiles('./pnpm-lock.yaml', '/.npmrc) }} + # - name: Prisma Generate + # run: | + # pnpm prisma:gen:dev + # - name: Prisma Push + # run: | + # pnpm prisma:push:dev + # - name: Install Playwright Browsers + # run: | + # pnpm exec playwright install + # pnpm playwright install-deps chromium + # - name: e2e Test + # run: | + # pnpm run test:e2e:ci + # - uses: actions/upload-artifact@v4 + # if: ${{ !cancelled() }} + # with: + # name: playwright-report + # path: test-results/ + # retention-days: 5 + \ No newline at end of file