feat(ci): deploy review apps to mittwald Container Hosting #2
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 & Deploy Preview Apps | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - app: docs | |
| dockerfile: apps/docs/Dockerfile | |
| image_suffix: docs | |
| - app: storybook | |
| dockerfile: packages/components/Dockerfile | |
| image_suffix: storybook | |
| outputs: | |
| docs_image: ${{ steps.meta-docs.outputs.tags }} | |
| storybook_image: ${{ steps.meta-storybook.outputs.tags }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Log in to the Container registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata for Docs | |
| id: meta-docs | |
| if: matrix.image_suffix == 'docs' | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: | |
| ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/${{ matrix.image_suffix }} | |
| tags: | | |
| type=ref,event=branch | |
| type=ref,event=pr | |
| type=sha | |
| - name: Extract metadata for Storybook | |
| id: meta-storybook | |
| if: matrix.image_suffix == 'storybook' | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: | |
| ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/${{ matrix.image_suffix }} | |
| tags: | | |
| type=ref,event=branch | |
| type=ref,event=pr | |
| type=sha | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ${{ matrix.dockerfile }} | |
| push: true | |
| tags: | |
| ${{ matrix.image_suffix == 'docs' && steps.meta-docs.outputs.tags || | |
| steps.meta-storybook.outputs.tags }} | |
| labels: | |
| ${{ matrix.image_suffix == 'docs' && steps.meta-docs.outputs.labels | |
| || steps.meta-storybook.outputs.labels }} | |
| build-args: | | |
| NEXT_BASE_PATH= | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| permissions: | |
| contents: read | |
| packages: read | |
| pull-requests: write | |
| if: github.event_name == 'pull_request' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: "24" | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| - name: Deploy preview environment | |
| env: | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| MITTWALD_PROJECT_ID: ${{ secrets.MITTWALD_PROJECT_ID }} | |
| MITTWALD_API_TOKEN: ${{ secrets.MITTWALD_API_TOKEN }} | |
| DOCS_IMAGE_TAG: ${{ needs.build.outputs.docs_image }} | |
| STORYBOOK_IMAGE_TAG: ${{ needs.build.outputs.storybook_image }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GITHUB_REPOSITORY: ${{ github.repository }} | |
| run: | | |
| pnpm tsx dev/deploy-review.ts |