From 130dbab765a35cf6e74f3e7f6b795598a039b3ef Mon Sep 17 00:00:00 2001 From: "Kseniya A. Mikhaljova" Date: Thu, 25 Jul 2024 11:17:19 +0400 Subject: [PATCH] Adding workflow for tags --- .github/workflows/main.yml | 81 +++++++++++++++++++ .../Dockerfile => Dockerfile | 0 .../pipeline_monitoring/docker-compose.yml | 4 +- 3 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/main.yml rename samples/pipeline_monitoring/Dockerfile => Dockerfile (100%) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..9d78af8 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,81 @@ +name: main + +concurrency: + group: ${{ github.workflow }}-${{ github.ref_name }} + cancel-in-progress: true + +on: + push: + tags: [ 'v*.*.*' ] + branches: [ 'main' ] + +env: + REGISTRY: ghcr.io + +jobs: + docker: + runs-on: + - self-hosted + - ${{ matrix.runner }} + permissions: + contents: read + packages: write + id-token: write + strategy: + matrix: + include: + - docker_file: Dockerfile + name: pipeline-watchdog-arm64 + arch: linux/arm64 + tag: ghcr.io/insight-platform/pipeline-watchdog-arm64 + runner: ARM64 + - docker_file: Dockerfile + name: pipeline-watchdog-x86 + arch: linux/amd64 + tag: ghcr.io/insight-platform/pipeline-watchdog-x86 + runner: X64 + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Inject slug/short variables + uses: rlespinasse/github-slug-action@v4.4.1 + + # Set up BuildKit Docker container builder to be able to build + # multi-platform images and export cache + # https://github.com/docker/setup-buildx-action + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3.5.0 + + # https://github.com/docker/build-push-action + - name: Build docker image for ${{ env.GITHUB_REF_SLUG }} + uses: docker/build-push-action@v6.5.0 + with: + file: ${{ matrix.docker_file }} + platforms: ${{ matrix.arch }} + tags: "${{matrix.tag}}:${{ env.GITHUB_REF_SLUG }}" + load: true + context: . + cache-from: type=gha + cache-to: type=gha,mode=max + + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + uses: docker/login-action@v3.3.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ github.token }} + + # https://github.com/docker/build-push-action + - name: Push docker image for ${{ env.GITHUB_REF_SLUG }} + uses: docker/build-push-action@v6.5.0 + with: + file: ${{ matrix.docker_file }} + platforms: ${{ matrix.arch }} + tags: "${{matrix.tag}}:${{ env.GITHUB_REF_SLUG }}" + push: true + context: . + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/samples/pipeline_monitoring/Dockerfile b/Dockerfile similarity index 100% rename from samples/pipeline_monitoring/Dockerfile rename to Dockerfile diff --git a/samples/pipeline_monitoring/docker-compose.yml b/samples/pipeline_monitoring/docker-compose.yml index da60cca..00de75f 100644 --- a/samples/pipeline_monitoring/docker-compose.yml +++ b/samples/pipeline_monitoring/docker-compose.yml @@ -64,8 +64,8 @@ services: pipeline-watchdog: container_name: pipeline-watchdog build: - context: ../.. - dockerfile: ./samples/pipeline_monitoring/Dockerfile + context: ../../ + dockerfile: Dockerfile restart: unless-stopped network_mode: host volumes: