From 6a43782f2b667b5989f96381bcfcd43714817593 Mon Sep 17 00:00:00 2001 From: Xavier Vello Date: Fri, 3 May 2024 18:23:28 +0200 Subject: [PATCH] ci: refactor docker build workflows for all rust crates --- .../{docker-capture.yml => docker-build.yml} | 26 ++++--- .github/workflows/docker-hook-api.yml | 75 ------------------- .github/workflows/docker-hook-janitor.yml | 75 ------------------- .github/workflows/docker-hook-worker.yml | 75 ------------------- 4 files changed, 15 insertions(+), 236 deletions(-) rename .github/workflows/{docker-capture.yml => docker-build.yml} (77%) delete mode 100644 .github/workflows/docker-hook-api.yml delete mode 100644 .github/workflows/docker-hook-janitor.yml delete mode 100644 .github/workflows/docker-hook-worker.yml diff --git a/.github/workflows/docker-capture.yml b/.github/workflows/docker-build.yml similarity index 77% rename from .github/workflows/docker-capture.yml rename to .github/workflows/docker-build.yml index d31e05d..3132a61 100644 --- a/.github/workflows/docker-capture.yml +++ b/.github/workflows/docker-build.yml @@ -1,4 +1,4 @@ -name: Build capture docker image +name: Build container images on: workflow_dispatch: @@ -6,12 +6,16 @@ on: branches: - "main" -permissions: - packages: write - jobs: build: - name: build and publish capture image + name: Build and publish container image + strategy: + matrix: + image: + - capture + - hook-api + - hook-janitor + - hook-worker runs-on: depot-ubuntu-22.04-4 permissions: id-token: write # allow issuing OIDC tokens for this workflow run @@ -45,7 +49,7 @@ jobs: id: meta uses: docker/metadata-action@v4 with: - images: ghcr.io/posthog/hog-rs/capture + images: ghcr.io/posthog/hog-rs/${{ matrix.image }} tags: | type=ref,event=pr type=ref,event=branch @@ -57,8 +61,8 @@ jobs: id: buildx uses: docker/setup-buildx-action@v2 - - name: Build and push capture - id: docker_build_capture + - name: Build and push image + id: docker_build uses: depot/build-push-action@v1 with: context: ./ @@ -69,7 +73,7 @@ jobs: platforms: linux/arm64 cache-from: type=gha cache-to: type=gha,mode=max - build-args: BIN=capture + build-args: BIN=${{ matrix.image }} - - name: Capture image digest - run: echo ${{ steps.docker_build_capture.outputs.digest }} + - name: Container image digest + run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/.github/workflows/docker-hook-api.yml b/.github/workflows/docker-hook-api.yml deleted file mode 100644 index e6f83f1..0000000 --- a/.github/workflows/docker-hook-api.yml +++ /dev/null @@ -1,75 +0,0 @@ -name: Build hook-api docker image - -on: - workflow_dispatch: - push: - branches: - - "main" - -permissions: - packages: write - -jobs: - build: - name: build and publish hook-api image - runs-on: depot-ubuntu-22.04-4 - permissions: - id-token: write # allow issuing OIDC tokens for this workflow run - contents: read # allow reading the repo contents - packages: write # allow push to ghcr.io - - steps: - - name: Check Out Repo - uses: actions/checkout@v3 - - - name: Set up Depot CLI - uses: depot/setup-action@v1 - - - name: Login to DockerHub - uses: docker/login-action@v2 - with: - username: posthog - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Login to ghcr.io - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Docker meta - id: meta - uses: docker/metadata-action@v4 - with: - images: ghcr.io/posthog/hog-rs/hook-api - tags: | - type=ref,event=pr - type=ref,event=branch - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=sha - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v2 - - - name: Build and push api - id: docker_build_hook_api - uses: depot/build-push-action@v1 - with: - context: ./ - file: ./Dockerfile - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - platforms: linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=max - build-args: BIN=hook-api - - - name: Hook-api image digest - run: echo ${{ steps.docker_build_hook_api.outputs.digest }} diff --git a/.github/workflows/docker-hook-janitor.yml b/.github/workflows/docker-hook-janitor.yml deleted file mode 100644 index 33706d0..0000000 --- a/.github/workflows/docker-hook-janitor.yml +++ /dev/null @@ -1,75 +0,0 @@ -name: Build hook-janitor docker image - -on: - workflow_dispatch: - push: - branches: - - "main" - -permissions: - packages: write - -jobs: - build: - name: build and publish hook-janitor image - runs-on: depot-ubuntu-22.04-4 - permissions: - id-token: write # allow issuing OIDC tokens for this workflow run - contents: read # allow reading the repo contents - packages: write # allow push to ghcr.io - - steps: - - name: Check Out Repo - uses: actions/checkout@v3 - - - name: Set up Depot CLI - uses: depot/setup-action@v1 - - - name: Login to DockerHub - uses: docker/login-action@v2 - with: - username: posthog - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Login to ghcr.io - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Docker meta - id: meta - uses: docker/metadata-action@v4 - with: - images: ghcr.io/posthog/hog-rs/hook-janitor - tags: | - type=ref,event=pr - type=ref,event=branch - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=sha - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v2 - - - name: Build and push janitor - id: docker_build_hook_janitor - uses: depot/build-push-action@v1 - with: - context: ./ - file: ./Dockerfile - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - platforms: linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=max - build-args: BIN=hook-janitor - - - name: Hook-janitor image digest - run: echo ${{ steps.docker_build_hook_janitor.outputs.digest }} diff --git a/.github/workflows/docker-hook-worker.yml b/.github/workflows/docker-hook-worker.yml deleted file mode 100644 index dc5ca53..0000000 --- a/.github/workflows/docker-hook-worker.yml +++ /dev/null @@ -1,75 +0,0 @@ -name: Build hook-worker docker image - -on: - workflow_dispatch: - push: - branches: - - "main" - -permissions: - packages: write - -jobs: - build: - name: build and publish hook-worker image - runs-on: depot-ubuntu-22.04-4 - permissions: - id-token: write # allow issuing OIDC tokens for this workflow run - contents: read # allow reading the repo contents - packages: write # allow push to ghcr.io - - steps: - - name: Check Out Repo - uses: actions/checkout@v3 - - - name: Set up Depot CLI - uses: depot/setup-action@v1 - - - name: Login to DockerHub - uses: docker/login-action@v2 - with: - username: posthog - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Login to ghcr.io - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Docker meta - id: meta - uses: docker/metadata-action@v4 - with: - images: ghcr.io/posthog/hog-rs/hook-worker - tags: | - type=ref,event=pr - type=ref,event=branch - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=sha - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v2 - - - name: Build and push worker - id: docker_build_hook_worker - uses: depot/build-push-action@v1 - with: - context: ./ - file: ./Dockerfile - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - platforms: linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=max - build-args: BIN=hook-worker - - - name: Hook-worker image digest - run: echo ${{ steps.docker_build_hook_worker.outputs.digest }}