[do not merge] Allow to debug docker images #379
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: Build | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| inputs: | |
| release: | |
| description: "Create a release" | |
| required: false | |
| default: false | |
| type: boolean | |
| env: | |
| NODE_VERSION: 22 | |
| FLYCTL_VERSION: 0.3.95 | |
| FRONTEND_INTERNAL_PORT: 3000 | |
| CMS_INTERNAL_PORT: 3001 | |
| jobs: | |
| version: | |
| name: "Generate version" | |
| uses: ./.github/workflows/version.yml | |
| with: | |
| release: ${{ github.event.inputs.release }} | |
| populate-cms-types: | |
| name: "Populate CMS types" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup | |
| uses: ./.github/actions/setup | |
| - name: Install CMS dependencies | |
| run: pnpm --filter cms install | |
| - name: Pull CMS types | |
| run: pnpm --filter payload-types pull-payload-types | |
| - name: Upload CMS types | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: payload-types | |
| path: libs/payload-types/src/payload-types.ts | |
| frontend-lint: | |
| name: "Frontend: Lint" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup | |
| uses: ./.github/actions/setup | |
| - name: Install dependencies | |
| run: pnpm --filter frontend install | |
| - name: Run lint in frontend | |
| run: pnpm --filter frontend lint --max-warnings=0 | |
| frontend-check-format: | |
| name: "Frontend: Check Format" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup | |
| uses: ./.github/actions/setup | |
| - name: Install dependencies | |
| run: pnpm --filter frontend install | |
| - name: Check format in frontend | |
| run: pnpm --filter frontend check-format | |
| frontend-typecheck: | |
| name: "Frontend: Typecheck" | |
| runs-on: ubuntu-latest | |
| needs: populate-cms-types | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup | |
| uses: ./.github/actions/setup | |
| - name: Download CMS types | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: payload-types | |
| path: libs/payload-types/src | |
| - name: Install dependencies | |
| run: pnpm --filter frontend install | |
| - name: Run typecheck in frontend | |
| run: pnpm --filter frontend typecheck | |
| frontend-unit-tests: | |
| name: "Frontend: Unit Tests" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup | |
| uses: ./.github/actions/setup | |
| - name: Install dependencies | |
| run: pnpm --filter frontend install | |
| - name: Run unit tests in frontend | |
| run: pnpm --filter frontend test | |
| frontend-build-push: | |
| name: "Frontend: Build and Push" | |
| runs-on: ubuntu-latest | |
| needs: [populate-cms-types, version] | |
| outputs: | |
| image: ${{ steps.image-name.outputs.image }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up flyctl | |
| uses: superfly/flyctl-actions/setup-flyctl@master | |
| with: | |
| version: ${{ env.FLYCTL_VERSION }} | |
| - name: Setup | |
| uses: ./.github/actions/setup | |
| - name: Set version on frontend | |
| run: | | |
| pnpm version ${{ needs.version.outputs.version }} --git-tag-version false | |
| working-directory: apps/frontend | |
| - name: Download CMS types | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: payload-types | |
| path: libs/payload-types/src | |
| - name: Get frontend image name | |
| id: image-name | |
| run: | | |
| IMAGE_NAME=${{ vars.FLY_STAGING_FRONTEND_APP }} | |
| IMAGE_TAG=v${{ needs.version.outputs.version_with_sha }} | |
| echo "image_name=$IMAGE_NAME" >> "$GITHUB_OUTPUT" | |
| echo "image_tag=$IMAGE_TAG" >> "$GITHUB_OUTPUT" | |
| echo "image=registry.fly.io/$IMAGE_NAME:$IMAGE_TAG" >> "$GITHUB_OUTPUT" | |
| - name: Build and push frontend Docker image | |
| run: | | |
| flyctl deploy \ | |
| --app ${{ steps.image-name.outputs.image_name }} \ | |
| --config apps/frontend/fly.build.toml \ | |
| --build-only \ | |
| --image-label ${{ steps.image-name.outputs.image_tag }} \ | |
| --label org.opencontainers.image.version=${{ steps.image-name.outputs.image_tag }} \ | |
| --push \ | |
| env: | |
| FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
| cms-lint: | |
| name: "CMS: Lint" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup | |
| uses: ./.github/actions/setup | |
| - name: Install dependencies | |
| run: pnpm --filter cms install | |
| - name: Run lint | |
| run: pnpm --filter cms lint --max-warnings=0 | |
| cms-check-format: | |
| name: "CMS: Check Format" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup | |
| uses: ./.github/actions/setup | |
| - name: Install dependencies | |
| run: pnpm --filter cms install | |
| - name: Check format in frontend | |
| run: pnpm --filter cms check-format | |
| cms-build-push: | |
| name: "CMS: Build and Push" | |
| runs-on: ubuntu-latest | |
| needs: [version] | |
| outputs: | |
| image: ${{ steps.image-name.outputs.image }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up flyctl | |
| uses: superfly/flyctl-actions/setup-flyctl@master | |
| with: | |
| version: ${{ env.FLYCTL_VERSION }} | |
| - name: Setup | |
| uses: ./.github/actions/setup | |
| - name: Set version on CMS | |
| run: | | |
| pnpm version ${{ needs.version.outputs.version }} --git-tag-version false | |
| working-directory: apps/cms | |
| - name: Get CMS image name | |
| id: image-name | |
| run: | | |
| IMAGE_NAME=${{ vars.FLY_STAGING_CMS_APP }} | |
| IMAGE_TAG=v${{ needs.version.outputs.version_with_sha }} | |
| echo "image_name=$IMAGE_NAME" >> "$GITHUB_OUTPUT" | |
| echo "image_tag=$IMAGE_TAG" >> "$GITHUB_OUTPUT" | |
| echo "image=registry.fly.io/$IMAGE_NAME:$IMAGE_TAG" >> "$GITHUB_OUTPUT" | |
| - name: Build and push CMS Docker image | |
| run: | | |
| flyctl deploy \ | |
| --app ${{ steps.image-name.outputs.image_name }} \ | |
| --config apps/cms/fly.build.toml \ | |
| --build-only \ | |
| --image-label ${{ steps.image-name.outputs.image_tag }} \ | |
| --label org.opencontainers.image.version=${{ steps.image-name.outputs.image_tag }} \ | |
| --push \ | |
| env: | |
| FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
| e2e-tests: | |
| name: End-to-End Tests | |
| timeout-minutes: 60 | |
| runs-on: ubuntu-latest | |
| needs: [populate-cms-types, version, frontend-build-push, cms-build-push] | |
| env: | |
| CMS_API_KEY: e2e-tests-apikey | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup | |
| uses: ./.github/actions/setup | |
| - name: Install dependencies for e2e | |
| run: pnpm --filter e2e install | |
| - name: Set up flyctl | |
| uses: superfly/flyctl-actions/setup-flyctl@master | |
| with: | |
| version: ${{ env.FLYCTL_VERSION }} | |
| - name: Authenticate Fly.io Docker registry | |
| run: flyctl auth docker | |
| env: | |
| FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
| - name: Start services | |
| run: docker compose up -d && sleep 3 | |
| env: | |
| FRONTEND_IMAGE: ${{ needs.frontend-build-push.outputs.image }} | |
| CMS_API_KEY: ${{ env.CMS_API_KEY }} | |
| CMS_IMAGE: ${{ needs.cms-build-push.outputs.image }} | |
| PAYLOAD_SECRET: $(openssl rand -hex 12) | |
| MEDIA_S3_BUCKET: ${{ vars.E2E_TESTS_MEDIA_S3_BUCKET }} | |
| MEDIA_S3_REGION: ${{ vars.E2E_TESTS_MEDIA_S3_REGION }} | |
| MEDIA_S3_ACCESS_KEY_ID: | |
| ${{ secrets.E2E_TESTS_MEDIA_S3_ACCESS_KEY_ID }} | |
| MEDIA_S3_SECRET_ACCESS_KEY: | |
| ${{ secrets.E2E_TESTS_MEDIA_S3_SECRET_ACCESS_KEY }} | |
| OPENAI_API_KEY: ${{ secrets.E2E_TESTS_OPENAI_API_KEY }} | |
| IMAGEKIT_BASE_URL: ${{ vars.E2E_TESTS_IMAGEKIT_BASE_URL }} | |
| working-directory: tests/e2e | |
| - name: Get Playwright version | |
| id: playwright-version | |
| run: | | |
| PLAYWRIGHT_VERSION=$(pnpm list @playwright/test --depth=0 | grep '@playwright/test' | awk '{print $2}') | |
| echo "playwright_version=${PLAYWRIGHT_VERSION}" >> $GITHUB_OUTPUT | |
| working-directory: tests/e2e | |
| - name: Cache Playwright browsers | |
| uses: actions/cache@v4 | |
| id: playwright-cache | |
| with: | |
| path: ~/.cache/ms-playwright | |
| key: | |
| ${{ runner.os }}-playwright-${{ | |
| steps.playwright-version.outputs.playwright_version }} | |
| - name: Install Playwright dependencies | |
| run: pnpm playwright install --with-deps chromium | |
| if: steps.playwright-cache.outputs.cache-hit != 'true' | |
| working-directory: tests/e2e | |
| - name: Download CMS types | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: payload-types | |
| path: libs/payload-types/src | |
| - name: Run e2e tests | |
| run: pnpm playwright test | |
| working-directory: tests/e2e | |
| env: | |
| FRONTEND_BASE_URL: http://localhost:${{ env.FRONTEND_INTERNAL_PORT }} | |
| CMS_BASE_URL: http://localhost:${{ env.CMS_INTERNAL_PORT }} | |
| CMS_API_KEY: ${{ env.CMS_API_KEY }} | |
| EXPECTED_VERSION: ${{ needs.version.outputs.version }} | |
| - name: Upload Playwright report | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: playwright-report | |
| path: tests/e2e/playwright-report/ | |
| retention-days: 30 | |
| deploy: | |
| name: Deploy | |
| needs: | |
| - version | |
| - frontend-lint | |
| - frontend-check-format | |
| - frontend-typecheck | |
| - frontend-unit-tests | |
| - frontend-build-push | |
| - cms-lint | |
| - cms-check-format | |
| - cms-build-push | |
| - e2e-tests | |
| if: github.event_name != 'pull_request' | |
| uses: ./.github/workflows/deploy-version.yml | |
| with: | |
| version_with_sha: ${{ needs.version.outputs.version_with_sha }} | |
| environment: staging | |
| secrets: inherit | |
| create-release: | |
| name: Create release | |
| runs-on: ubuntu-latest | |
| if: needs.version.outputs.is_new_release == 'true' | |
| needs: [deploy, version] | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout with full history | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup | |
| uses: ./.github/actions/setup | |
| - name: Install dependencies | |
| run: pnpm --filter releaser install | |
| - name: Create release | |
| run: | | |
| pnpm --filter releaser start publish --draft ${{ needs.version.outputs.version }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |