feat: split docker-compose into backend and web networks #32
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: CI / Release | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| # ------------------------------------------------------- | |
| # Test: runs on every push and PR | |
| # ------------------------------------------------------- | |
| test: | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:16-alpine | |
| env: | |
| POSTGRES_USER: gitbacker | |
| POSTGRES_PASSWORD: gitbacker | |
| POSTGRES_DB: gitbacker | |
| ports: ["5432:5432"] | |
| options: >- | |
| --health-cmd "pg_isready -U gitbacker" | |
| --health-interval 5s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| redis: | |
| image: redis:7-alpine | |
| ports: ["6379:6379"] | |
| options: >- | |
| --health-cmd "redis-cli ping" | |
| --health-interval 5s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| # --- Python backend --- | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - uses: astral-sh/setup-uv@v4 | |
| - name: Test API | |
| working-directory: backend/api | |
| env: | |
| DATABASE_URL: postgresql+asyncpg://gitbacker:gitbacker@localhost:5432/gitbacker | |
| REDIS_URL: redis://localhost:6379/0 | |
| JWT_SECRET: ci-test-secret-not-for-production | |
| run: | | |
| uv sync --extra dev | |
| uv run pytest tests/ -x --tb=short | |
| - name: Test backup-core | |
| working-directory: backend/backup-core | |
| run: | | |
| uv sync --extra dev | |
| uv run pytest tests/ -x --tb=short | |
| # --- Frontend --- | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| - uses: pnpm/action-setup@v4 | |
| with: | |
| version: latest | |
| - name: Frontend lint & typecheck | |
| working-directory: frontend | |
| run: | | |
| pnpm install --frozen-lockfile | |
| pnpm tsc --noEmit | |
| # ------------------------------------------------------- | |
| # Release: semantic-release on main only | |
| # ------------------------------------------------------- | |
| release: | |
| needs: test | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| issues: write | |
| pull-requests: write | |
| outputs: | |
| new_release_published: ${{ steps.semantic.outputs.new_release_published }} | |
| new_release_version: ${{ steps.semantic.outputs.new_release_version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| - name: Semantic Release | |
| id: semantic | |
| uses: cycjimmy/semantic-release-action@v4 | |
| with: | |
| semantic_version: 24 | |
| extra_plugins: | | |
| @semantic-release/changelog | |
| @semantic-release/exec | |
| @semantic-release/git | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # ------------------------------------------------------- | |
| # Docker: build & push images on new release | |
| # ------------------------------------------------------- | |
| docker: | |
| needs: release | |
| if: needs.release.outputs.new_release_published == 'true' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| packages: write | |
| strategy: | |
| matrix: | |
| include: | |
| - image: gitbacker-api | |
| dockerfile: infra/docker/Dockerfile.api | |
| - image: gitbacker-worker | |
| dockerfile: infra/docker/Dockerfile.worker | |
| - image: gitbacker-frontend | |
| dockerfile: infra/docker/Dockerfile.frontend | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ${{ matrix.dockerfile }} | |
| platforms: linux/amd64 | |
| push: true | |
| tags: | | |
| ghcr.io/${{ github.repository_owner }}/${{ matrix.image }}:${{ needs.release.outputs.new_release_version }} | |
| ghcr.io/${{ github.repository_owner }}/${{ matrix.image }}:latest | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |