2021-09-13 19:36:12 +02:00
|
|
|
name: Build images
|
|
|
|
|
|
|
|
on:
|
|
|
|
release:
|
|
|
|
types:
|
|
|
|
- published
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- 'trunk'
|
|
|
|
paths-ignore:
|
|
|
|
- '.env*'
|
|
|
|
- 'docker-compose*.yaml'
|
|
|
|
- '*/rhel/*'
|
|
|
|
- '*/windows/*'
|
|
|
|
- "**.md"
|
|
|
|
|
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
shell: bash
|
|
|
|
|
2021-09-14 11:41:09 +02:00
|
|
|
env:
|
|
|
|
DOCKER_REPOSITORY: "zabbix"
|
|
|
|
LATEST_BRANCH: ${{ github.event.repository.default_branch }}
|
2021-09-14 12:32:06 +02:00
|
|
|
BASE_BUILD_NAME: "build-base"
|
2021-09-14 11:41:09 +02:00
|
|
|
|
2021-09-13 19:36:12 +02:00
|
|
|
jobs:
|
2021-09-14 02:17:14 +02:00
|
|
|
init_build:
|
|
|
|
name: Initialize build
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
2021-09-14 03:10:41 +02:00
|
|
|
os: ${{ steps.os.outputs.list }}
|
|
|
|
database: ${{ steps.database.outputs.list }}
|
|
|
|
components: ${{ steps.components.outputs.list }}
|
2021-09-14 02:17:14 +02:00
|
|
|
steps:
|
2021-09-14 12:32:06 +02:00
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v2
|
2021-09-14 11:41:09 +02:00
|
|
|
with:
|
|
|
|
fetch-depth: 1
|
|
|
|
|
2021-09-14 12:32:06 +02:00
|
|
|
- name: Check build.xml file
|
|
|
|
id: build_exists
|
2021-09-14 03:10:41 +02:00
|
|
|
run: |
|
2021-09-14 12:32:06 +02:00
|
|
|
if [[ ! -f "./build.xml" ]]; then
|
|
|
|
echo "::error::File build.xml is missing"
|
|
|
|
exit 1
|
2021-09-14 11:41:09 +02:00
|
|
|
fi
|
|
|
|
|
2021-09-14 12:32:06 +02:00
|
|
|
- name: Prepare Operating System list
|
|
|
|
id: os
|
|
|
|
run: |
|
|
|
|
os_list=$(jq -r '.os | keys | [ .[] | tostring ] | @json' "./build.xml")
|
|
|
|
|
|
|
|
echo "::set-output name=list::$os_list"
|
2021-09-14 03:10:41 +02:00
|
|
|
|
2021-09-14 12:32:06 +02:00
|
|
|
- name: Prepare Platform list
|
|
|
|
id: platform_list
|
|
|
|
run: |
|
|
|
|
platform_list=$(jq -r '.os | tostring | @json' "./build.xml")
|
|
|
|
|
|
|
|
echo "::set-output name=list::$platform_list"
|
|
|
|
|
|
|
|
- name: Prepare Database engine list
|
2021-09-14 03:10:41 +02:00
|
|
|
id: database
|
|
|
|
run: |
|
2021-09-14 12:32:06 +02:00
|
|
|
database_list=$(jq -r '[.components | values[] ] | sort | unique | del(.. | select ( . == "" ) ) | [ .[] | tostring ] | @json' "./build.xml")
|
|
|
|
|
|
|
|
echo "::set-output name=list::$database_list"
|
2021-09-14 03:10:41 +02:00
|
|
|
|
2021-09-14 12:32:06 +02:00
|
|
|
- name: Prepare Zabbix component list
|
2021-09-14 03:10:41 +02:00
|
|
|
id: components
|
|
|
|
run: |
|
2021-09-14 12:32:06 +02:00
|
|
|
component_list=$(jq -r '.components | keys | [ .[] | tostring ] | @json' "./build.xml")
|
|
|
|
|
2021-09-14 12:32:43 +02:00
|
|
|
echo "::set-output name=list::$component_list"
|
2021-09-14 03:10:41 +02:00
|
|
|
|
2021-09-13 19:36:12 +02:00
|
|
|
build_base:
|
|
|
|
timeout-minutes: 70
|
2021-09-14 12:32:06 +02:00
|
|
|
name: Build base on ${{ matrix.os }}
|
2021-09-14 02:18:47 +02:00
|
|
|
needs: init_build
|
2021-09-13 19:36:12 +02:00
|
|
|
strategy:
|
2021-09-14 03:10:41 +02:00
|
|
|
fail-fast: false
|
2021-09-13 19:36:12 +02:00
|
|
|
matrix:
|
2021-09-14 02:17:14 +02:00
|
|
|
os: ${{ fromJson(needs.init_build.outputs.os) }}
|
2021-09-13 19:36:12 +02:00
|
|
|
|
2021-09-14 03:10:41 +02:00
|
|
|
runs-on: ubuntu-latest
|
2021-09-13 19:36:12 +02:00
|
|
|
steps:
|
2021-09-14 12:32:06 +02:00
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v2
|
2021-09-14 02:17:14 +02:00
|
|
|
with:
|
|
|
|
fetch-depth: 1
|
2021-09-13 19:36:12 +02:00
|
|
|
|
|
|
|
- name: Set up QEMU
|
|
|
|
uses: docker/setup-qemu-action@v1
|
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
|
|
|
|
- name: Login to DockerHub
|
|
|
|
uses: docker/login-action@v1
|
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
|
2021-09-14 12:32:06 +02:00
|
|
|
- name: Prepare Platform list
|
|
|
|
id: platform_list
|
2021-09-13 19:36:12 +02:00
|
|
|
run: |
|
2021-09-14 12:32:06 +02:00
|
|
|
platform_list=$(jq -r '.os.${{ matrix.os }} | join(",")' "./build.xml")
|
2021-09-13 19:36:12 +02:00
|
|
|
|
2021-09-14 12:35:54 +02:00
|
|
|
echo ::set-output name=list::$platform_list
|
2021-09-13 19:36:12 +02:00
|
|
|
|
2021-09-14 14:36:19 +02:00
|
|
|
- name: Docker meta
|
|
|
|
id: meta
|
|
|
|
uses: docker/metadata-action@v3
|
|
|
|
with:
|
|
|
|
images: ${{ env.DOCKER_REPOSITORY }}/zabbix-${{ env.BASE_BUILD_NAME }}
|
|
|
|
tags: |
|
|
|
|
type=ref,event=branch,prefix=${{ matrix.os }}-
|
|
|
|
type=ref,event=branch,suffix=-${{ matrix.os }}
|
2021-09-13 19:36:12 +02:00
|
|
|
|
|
|
|
- name: Build and push
|
|
|
|
id: docker_build
|
|
|
|
uses: docker/build-push-action@v2
|
|
|
|
with:
|
2021-09-14 12:33:46 +02:00
|
|
|
context: ./${{ env.BASE_BUILD_NAME }}/${{ matrix.os }}
|
|
|
|
file: ./${{ env.BASE_BUILD_NAME }}/${{ matrix.os }}/Dockerfile
|
2021-09-13 19:36:12 +02:00
|
|
|
platforms: ${{ steps.platform.outputs.list }}
|
|
|
|
push: ${{ secrets.AUTO_PUSH_IMAGES }}
|
2021-09-14 14:36:19 +02:00
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
2021-09-13 19:36:12 +02:00
|
|
|
|
|
|
|
- name: Image digest
|
2021-09-13 21:04:05 +02:00
|
|
|
run: |
|
|
|
|
echo ${{ steps.docker_build.outputs.digest }}
|
2021-09-14 12:33:46 +02:00
|
|
|
echo "${{ steps.docker_build.outputs.digest }}" > ${{ env.BASE_BUILD_NAME }}_${{ matrix.os }}
|
2021-09-13 21:17:54 +02:00
|
|
|
|
|
|
|
- uses: actions/upload-artifact@v2
|
|
|
|
with:
|
2021-09-14 12:33:46 +02:00
|
|
|
name: ${{ env.BASE_BUILD_NAME }}_${{ matrix.os }}
|
|
|
|
path: ${{ env.BASE_BUILD_NAME }}_${{ matrix.os }}
|
2021-09-13 21:26:49 +02:00
|
|
|
if-no-files-found: error
|
2021-09-13 19:36:12 +02:00
|
|
|
|
|
|
|
build_base_database:
|
|
|
|
timeout-minutes: 70
|
2021-09-14 02:18:47 +02:00
|
|
|
needs: [ "build_base", "init_build"]
|
2021-09-13 19:42:05 +02:00
|
|
|
name: Build ${{ matrix.build }} base on ${{ matrix.os }}
|
2021-09-13 19:36:12 +02:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
2021-09-14 03:10:41 +02:00
|
|
|
build: ${{ fromJson(needs.init_build.outputs.database) }}
|
2021-09-14 02:17:14 +02:00
|
|
|
os: ${{ fromJson(needs.init_build.outputs.os) }}
|
2021-09-13 19:36:12 +02:00
|
|
|
|
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Set up QEMU
|
|
|
|
uses: docker/setup-qemu-action@v1
|
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
|
|
|
|
- name: Login to DockerHub
|
|
|
|
uses: docker/login-action@v1
|
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
|
2021-09-14 12:32:06 +02:00
|
|
|
- name: Prepare Platform list
|
|
|
|
id: platform_list
|
2021-09-13 19:36:12 +02:00
|
|
|
run: |
|
2021-09-14 12:32:06 +02:00
|
|
|
platform_list=$(jq -r '.os.${{ matrix.os }} | join(",")' "./build.xml")
|
2021-09-13 19:36:12 +02:00
|
|
|
|
2021-09-14 12:36:08 +02:00
|
|
|
echo ::set-output name=list::$platform_list
|
2021-09-13 19:36:12 +02:00
|
|
|
|
2021-09-14 14:36:19 +02:00
|
|
|
- name: Docker meta
|
|
|
|
id: meta
|
|
|
|
uses: docker/metadata-action@v3
|
2021-09-13 21:17:54 +02:00
|
|
|
with:
|
2021-09-14 14:36:19 +02:00
|
|
|
images: ${{ env.DOCKER_REPOSITORY }}/zabbix-${{ matrix.build }}
|
|
|
|
tags: |
|
|
|
|
type=ref,event=branch,prefix=${{ matrix.os }}-
|
|
|
|
type=ref,event=branch,suffix=-${{ matrix.os }}
|
2021-09-13 21:17:54 +02:00
|
|
|
|
2021-09-14 14:49:54 +02:00
|
|
|
- uses: actions/download-artifact@v2
|
|
|
|
with:
|
|
|
|
name: build-base_${{ matrix.os }}
|
|
|
|
|
2021-09-14 14:36:19 +02:00
|
|
|
- name: Retrieve base build SHA256 tag
|
|
|
|
id: base_build
|
2021-09-13 19:36:12 +02:00
|
|
|
run: |
|
2021-09-13 22:01:07 +02:00
|
|
|
BASE_TAG=$(cat build-base_${{ matrix.os }})
|
2021-09-14 14:36:19 +02:00
|
|
|
BUILD_BASE_IMAGE=${{ env.DOCKER_REPOSITORY }}/zabbix-build-base@${{ steps.base_build.outputs.base_tag }}
|
2021-09-13 21:04:05 +02:00
|
|
|
|
2021-09-13 19:36:12 +02:00
|
|
|
echo ::set-output name=base_tag::${BASE_TAG}
|
2021-09-14 14:36:19 +02:00
|
|
|
echo ::set-output name=base_build_image::${BUILD_BASE_IMAGE}
|
2021-09-13 21:17:54 +02:00
|
|
|
|
2021-09-13 19:36:12 +02:00
|
|
|
- name: Build and push
|
|
|
|
id: docker_build
|
|
|
|
uses: docker/build-push-action@v2
|
|
|
|
with:
|
|
|
|
context: ./${{ matrix.build }}/${{ matrix.os }}
|
|
|
|
file: ./${{ matrix.build }}/${{ matrix.os }}/Dockerfile
|
|
|
|
platforms: ${{ steps.platform.outputs.list }}
|
|
|
|
push: ${{ secrets.AUTO_PUSH_IMAGES }}
|
2021-09-14 14:36:19 +02:00
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
build-args: BUILD_BASE_IMAGE=${{ steps.base_build.outputs.base_build_image }}
|
2021-09-13 23:06:45 +02:00
|
|
|
|
|
|
|
- name: Image digest
|
2021-09-14 04:55:24 +02:00
|
|
|
run: |
|
|
|
|
echo ${{ steps.docker_build.outputs.digest }}
|
|
|
|
echo "${{ steps.docker_build.outputs.digest }}" > ${{ matrix.build }}_${{ matrix.os }}
|
2021-09-13 23:06:45 +02:00
|
|
|
|
|
|
|
- uses: actions/upload-artifact@v2
|
|
|
|
with:
|
|
|
|
name: ${{ matrix.build }}_${{ matrix.os }}
|
|
|
|
path: ${{ matrix.build }}_${{ matrix.os }}
|
|
|
|
if-no-files-found: error
|
|
|
|
|
|
|
|
build_images:
|
|
|
|
timeout-minutes: 70
|
2021-09-14 02:18:47 +02:00
|
|
|
needs: [ "build_base_database", "init_build"]
|
2021-09-13 23:06:45 +02:00
|
|
|
name: Build ${{ matrix.build }} base on ${{ matrix.os }}
|
|
|
|
strategy:
|
2021-09-14 14:36:19 +02:00
|
|
|
fail-fast: false
|
2021-09-13 23:06:45 +02:00
|
|
|
matrix:
|
2021-09-14 03:10:41 +02:00
|
|
|
build: ${{ fromJson(needs.init_build.outputs.components) }}
|
2021-09-14 02:17:14 +02:00
|
|
|
os: ${{ fromJson(needs.init_build.outputs.os) }}
|
2021-09-13 23:06:45 +02:00
|
|
|
|
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Set up QEMU
|
|
|
|
uses: docker/setup-qemu-action@v1
|
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
|
|
|
|
- name: Login to DockerHub
|
|
|
|
uses: docker/login-action@v1
|
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
|
|
|
|
- name: Detect Build Base Image
|
|
|
|
id: build_base_image
|
|
|
|
run: |
|
2021-09-14 14:36:19 +02:00
|
|
|
BUILD_BASE=$(jq -r '.components."${{ matrix.build }}"' "./build.xml")
|
2021-09-13 23:06:45 +02:00
|
|
|
|
|
|
|
echo ::set-output name=build_base::${BUILD_BASE}
|
|
|
|
|
|
|
|
- uses: actions/download-artifact@v2
|
|
|
|
with:
|
|
|
|
name: ${{ steps.build_base_image.outputs.build_base }}_${{ matrix.os }}
|
|
|
|
|
2021-09-14 14:36:19 +02:00
|
|
|
- name: Retrieve base build SHA256 tag
|
|
|
|
id: base_build
|
2021-09-13 23:06:45 +02:00
|
|
|
run: |
|
|
|
|
BASE_TAG=$(cat ${{ steps.build_base_image.outputs.build_base }}_${{ matrix.os }})
|
2021-09-14 14:36:19 +02:00
|
|
|
BUILD_BASE_IMAGE=${{ env.DOCKER_REPOSITORY }}/zabbix-${{ steps.build_base_image.outputs.build_base }}@${BASE_TAG}
|
2021-09-13 23:06:45 +02:00
|
|
|
|
|
|
|
echo ::set-output name=base_tag::${BASE_TAG}
|
2021-09-14 14:36:19 +02:00
|
|
|
echo ::set-output name=base_build_image::${BUILD_BASE_IMAGE}
|
2021-09-13 23:06:45 +02:00
|
|
|
|
|
|
|
- name: Build and push
|
|
|
|
id: docker_build
|
|
|
|
uses: docker/build-push-action@v2
|
|
|
|
with:
|
|
|
|
context: ./${{ matrix.build }}/${{ matrix.os }}
|
|
|
|
file: ./${{ matrix.build }}/${{ matrix.os }}/Dockerfile
|
|
|
|
platforms: ${{ steps.platform.outputs.list }}
|
2021-09-14 07:21:16 +02:00
|
|
|
push: ${{ secrets.AUTO_PUSH_IMAGES }}
|
2021-09-13 23:06:45 +02:00
|
|
|
tags: ${{ steps.prepare_tags.outputs.image_tag_versions }}
|
2021-09-14 14:36:19 +02:00
|
|
|
build-args: BUILD_BASE_IMAGE=${{ steps.base_build.outputs.base_build_image }}
|
2021-09-13 19:36:12 +02:00
|
|
|
|
|
|
|
- name: Image digest
|
|
|
|
run: echo ${{ steps.docker_build.outputs.digest }}
|