DO-NOT-MERGE: Cloud engine controller #3
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 and push Cloud Engine Controller images | |
| on: | |
| push: | |
| paths: | |
| - cloud_engine_frontend/** | |
| - rs/cloud-engine-controller-backend/** | |
| - .github/workflows/cloud-engine-controller.yaml | |
| branches: | |
| - "main" | |
| pull_request: | |
| paths: | |
| - cloud_engine_frontend/** | |
| - rs/cloud-engine-controller-backend/** | |
| - .github/workflows/cloud-engine-controller.yaml | |
| merge_group: | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| REGISTRY: ghcr.io | |
| FRONTEND_IMAGE: ghcr.io/dfinity/dre/cloud-engine-frontend | |
| BACKEND_IMAGE: ghcr.io/dfinity/dre/cloud-engine-backend | |
| jobs: | |
| detect-changes: | |
| runs-on: ubuntu-22.04 | |
| outputs: | |
| frontend: ${{ steps.changes.outputs.frontend }} | |
| backend: ${{ steps.changes.outputs.backend }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dorny/paths-filter@v3 | |
| id: changes | |
| with: | |
| filters: | | |
| frontend: | |
| - 'cloud_engine_frontend/**' | |
| - '.github/workflows/cloud-engine-controller.yaml' | |
| backend: | |
| - 'rs/cloud-engine-controller-backend/**' | |
| - 'rs/ic-observability/service-discovery/**' | |
| - 'rs/ic-management-types/**' | |
| - 'Cargo.toml' | |
| - 'Cargo.lock' | |
| - '.github/workflows/cloud-engine-controller.yaml' | |
| build-frontend: | |
| runs-on: ubuntu-22.04 | |
| needs: detect-changes | |
| if: needs.detect-changes.outputs.frontend == 'true' || github.event_name == 'workflow_dispatch' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: "π§ Set up Docker Buildx" | |
| uses: docker/setup-buildx-action@v3 | |
| - name: "π Build frontend image" | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ./cloud_engine_frontend | |
| file: ./cloud_engine_frontend/Dockerfile | |
| push: false | |
| load: true | |
| tags: ${{ env.FRONTEND_IMAGE }}:${{ github.sha }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: "π§ Login to GitHub Container Registry" | |
| if: ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' }} | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: "π¦ Push frontend image to GitHub Container Registry" | |
| if: ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' }} | |
| run: | | |
| docker push ${{ env.FRONTEND_IMAGE }}:${{ github.sha }} | |
| build-backend: | |
| runs-on: ubuntu-22.04 | |
| needs: detect-changes | |
| if: needs.detect-changes.outputs.backend == 'true' || github.event_name == 'workflow_dispatch' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: "π§ Set up Docker Buildx" | |
| uses: docker/setup-buildx-action@v3 | |
| - name: "π Build backend image" | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./rs/cloud-engine-controller-backend/Dockerfile | |
| push: false | |
| load: true | |
| tags: ${{ env.BACKEND_IMAGE }}:${{ github.sha }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: "π§ Login to GitHub Container Registry" | |
| if: ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' }} | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: "π¦ Push backend image to GitHub Container Registry" | |
| if: ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' }} | |
| run: | | |
| docker push ${{ env.BACKEND_IMAGE }}:${{ github.sha }} | |
| update-k8s-deployments: | |
| runs-on: ubuntu-22.04 | |
| needs: [build-frontend, build-backend] | |
| if: | | |
| always() && | |
| (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) && | |
| (needs.build-frontend.result == 'success' || needs.build-backend.result == 'success') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: "π€ Update k8s deployments" | |
| uses: ./.github/workflows/update-k8s-deployments | |
| with: | |
| files-to-update: bases/apps/cloud-engine-controller/frontend/deployment.yaml bases/apps/cloud-engine-controller/backend/deployment.yaml | |
| push-token: ${{ secrets.K8S_API_TOKEN }} | |
| component: cloud-engine-controller |