2020-09-07 18:54:40 +02:00
|
|
|
name: CI
|
|
|
|
|
|
|
|
on:
|
|
|
|
release:
|
|
|
|
types:
|
|
|
|
- published
|
|
|
|
push:
|
|
|
|
branches:
|
2020-09-08 21:01:39 +02:00
|
|
|
- '3.0'
|
|
|
|
- '4.0'
|
|
|
|
- '5.0'
|
2021-02-15 16:18:59 +01:00
|
|
|
- '5.2'
|
2020-09-08 21:01:39 +02:00
|
|
|
- 'trunk'
|
2020-09-07 18:54:40 +02:00
|
|
|
paths-ignore:
|
|
|
|
- '.env*'
|
|
|
|
- 'docker-compose*.yaml'
|
|
|
|
- '*/rhel/*'
|
|
|
|
- "**.md"
|
|
|
|
|
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
shell: bash
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
2021-02-15 16:18:59 +01:00
|
|
|
timeout-minutes: 70
|
2020-09-07 18:54:40 +02:00
|
|
|
env:
|
2020-09-08 21:01:39 +02:00
|
|
|
LATEST_BRANCH: "${{ github.event.repository.default_branch }}"
|
2020-09-07 18:54:40 +02:00
|
|
|
DOCKER_REPOSITORY: "zabbix"
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
build:
|
|
|
|
- agent
|
|
|
|
- agent2
|
|
|
|
- java-gateway
|
|
|
|
- proxy-mysql
|
|
|
|
- proxy-sqlite3
|
|
|
|
- server-mysql
|
|
|
|
- server-pgsql
|
|
|
|
- snmptraps
|
|
|
|
- web-apache-mysql
|
|
|
|
- web-apache-pgsql
|
|
|
|
- web-nginx-mysql
|
|
|
|
- web-nginx-pgsql
|
|
|
|
os:
|
|
|
|
- alpine
|
|
|
|
- ubuntu
|
|
|
|
- centos
|
|
|
|
exclude:
|
|
|
|
- os: centos
|
|
|
|
build: agent2
|
|
|
|
- os: ubuntu
|
|
|
|
build: agent2
|
|
|
|
|
2021-02-15 16:18:59 +01:00
|
|
|
runs-on: ubuntu-20.04
|
2020-09-07 18:54:40 +02:00
|
|
|
steps:
|
2021-02-15 16:18:59 +01:00
|
|
|
-
|
|
|
|
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 }}
|
2020-09-07 23:16:26 +02:00
|
|
|
|
2020-09-07 18:54:40 +02:00
|
|
|
- name: Prepare platform list
|
|
|
|
id: platform
|
|
|
|
run: |
|
2021-03-17 17:05:27 +01:00
|
|
|
DOCKER_PLATFORM="linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x,linux/ppc64le"
|
2020-09-07 18:54:40 +02:00
|
|
|
|
|
|
|
if [ "${{ matrix.os }}" == "ubuntu" ]; then
|
2021-02-15 16:18:59 +01:00
|
|
|
DOCKER_PLATFORM="linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le"
|
2020-09-07 18:54:40 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "${{ matrix.os }}" == "centos" ]; then
|
2020-09-08 21:01:39 +02:00
|
|
|
DOCKER_PLATFORM="linux/amd64,linux/arm64,linux/ppc64le"
|
2020-09-07 18:54:40 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "${{ matrix.build }}" == "java-gateway" ]; then
|
|
|
|
DOCKER_PLATFORM=${DOCKER_PLATFORM%",linux/ppc64le"}
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo ::set-output name=list::${DOCKER_PLATFORM}
|
|
|
|
|
2020-09-07 23:16:26 +02:00
|
|
|
- name: Prepare environment (push)
|
2020-09-07 18:54:40 +02:00
|
|
|
if: github.event_name == 'push'
|
|
|
|
id: prepare_push
|
|
|
|
run: |
|
2020-09-07 23:16:26 +02:00
|
|
|
TAGS_ARRAY=()
|
|
|
|
|
2020-09-07 18:54:40 +02:00
|
|
|
IMAGE_NAME="${{ env.DOCKER_REPOSITORY }}/zabbix-${{ matrix.build }}"
|
|
|
|
GIT_BRANCH="${{ github.ref }}"
|
|
|
|
GIT_BRANCH=${GIT_BRANCH:11}
|
|
|
|
|
2020-09-08 21:01:39 +02:00
|
|
|
echo "::debug::Branch - ${GIT_BRANCH}"
|
2020-09-07 18:54:40 +02:00
|
|
|
|
2020-09-08 21:01:39 +02:00
|
|
|
if [ "${GIT_BRANCH}" == "trunk" ]; then
|
|
|
|
TAGS_ARRAY+=("$IMAGE_NAME:${{ matrix.os }}-${GIT_BRANCH}")
|
2021-02-16 14:57:28 +01:00
|
|
|
TAGS_ARRAY+=("$IMAGE_NAME:${GIT_BRANCH}-${{ matrix.os }}")
|
2020-09-08 21:01:39 +02:00
|
|
|
else
|
|
|
|
TAGS_ARRAY+=("$IMAGE_NAME:${{ matrix.os }}-${GIT_BRANCH}-latest")
|
2021-02-16 14:57:28 +01:00
|
|
|
TAGS_ARRAY+=("$IMAGE_NAME:${GIT_BRANCH}-${{ matrix.os }}-latest")
|
2020-09-08 21:01:39 +02:00
|
|
|
fi
|
2020-09-07 18:54:40 +02:00
|
|
|
|
|
|
|
if [ "${{ matrix.os }}" == "alpine" ] && [ "${LATEST_BRANCH}" == "${GIT_BRANCH}" ]; then
|
2020-09-07 23:16:26 +02:00
|
|
|
TAGS_ARRAY+=("$IMAGE_NAME:latest")
|
2020-09-07 18:54:40 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "${LATEST_BRANCH}" == "${GIT_BRANCH}" ]; then
|
2020-09-07 23:16:26 +02:00
|
|
|
TAGS_ARRAY+=("$IMAGE_NAME:${{ matrix.os }}-latest")
|
2020-09-07 18:54:40 +02:00
|
|
|
fi
|
|
|
|
|
2021-02-15 16:18:59 +01:00
|
|
|
TAGS=$(printf -- "%s, " "${TAGS_ARRAY[@]}")
|
2020-09-07 18:54:40 +02:00
|
|
|
|
2020-09-08 21:01:39 +02:00
|
|
|
echo "::debug::Tags - ${TAGS}"
|
2020-09-07 18:54:40 +02:00
|
|
|
|
|
|
|
echo ::set-output name=image_name::${IMAGE_NAME}
|
2021-02-15 16:18:59 +01:00
|
|
|
echo ::set-output name=image_tag_versions::$(printf -- "%s," "${TAGS_ARRAY[@]}")
|
2020-09-07 18:54:40 +02:00
|
|
|
|
2020-09-07 23:16:26 +02:00
|
|
|
- name: Prepare environment (release)
|
2020-09-08 21:01:39 +02:00
|
|
|
if: github.event_name == 'release' && github.event.action == 'published'
|
2020-09-07 18:54:40 +02:00
|
|
|
id: prepare_release
|
|
|
|
run: |
|
2020-09-07 23:16:26 +02:00
|
|
|
TAGS_ARRAY=()
|
|
|
|
|
2020-09-07 18:54:40 +02:00
|
|
|
IMAGE_NAME="${{ env.DOCKER_REPOSITORY }}/zabbix-${{ matrix.build }}"
|
|
|
|
RELEASE_VERSION="${{ github.ref }}"
|
|
|
|
RELEASE_VERSION=${RELEASE_VERSION:10}
|
|
|
|
GIT_BRANCH=${RELEASE_VERSION%.*}
|
|
|
|
|
2020-09-08 21:01:39 +02:00
|
|
|
echo "::debug::Release version ${RELEASE_VERSION}. Branch ${GIT_BRANCH}"
|
2020-09-07 18:54:40 +02:00
|
|
|
|
2020-09-07 23:16:26 +02:00
|
|
|
TAGS_ARRAY+=("$IMAGE_NAME:${{ matrix.os }}-${RELEASE_VERSION}")
|
2021-02-16 14:57:28 +01:00
|
|
|
TAGS_ARRAY+=("$IMAGE_NAME:${RELEASE_VERSION}-${{ matrix.os }}")
|
2020-09-07 18:54:40 +02:00
|
|
|
|
|
|
|
if [ "${{ matrix.os }}" == "alpine" ] && [ "${LATEST_BRANCH}" == "${GIT_BRANCH}" ]; then
|
2020-09-07 23:16:26 +02:00
|
|
|
TAGS_ARRAY+=("$IMAGE_NAME:latest")
|
2020-09-07 18:54:40 +02:00
|
|
|
fi
|
|
|
|
|
2020-09-07 23:16:26 +02:00
|
|
|
TAGS=$(printf -- "--tag %s " "${TAGS_ARRAY[@]}")
|
|
|
|
|
2020-09-07 18:54:40 +02:00
|
|
|
echo ::set-output name=image_name::${IMAGE_NAME}
|
2021-02-15 16:18:59 +01:00
|
|
|
echo ::set-output name=image_tag_versions::$(printf -- ",%s" "${TAGS_ARRAY[@]}")
|
2020-09-07 23:16:26 +02:00
|
|
|
|
2021-02-15 16:18:59 +01:00
|
|
|
- name: Prepare tags
|
|
|
|
id: prepare_tags
|
2020-09-07 23:16:26 +02:00
|
|
|
run: |
|
|
|
|
if [ ! -z "${{ steps.prepare_push.outputs.image_tag_versions }}" ]; then
|
2021-02-15 16:18:59 +01:00
|
|
|
TAGS="${{ steps.prepare_push.outputs.image_tag_versions }}"
|
|
|
|
IMAGE_NAME="${{ steps.prepare_push.outputs.image_name }}"
|
2020-09-07 23:16:26 +02:00
|
|
|
elif [ ! -z "${{ steps.prepare_release.outputs.image_tag_versions }}" ]; then
|
2021-02-15 16:18:59 +01:00
|
|
|
TAGS="${{ steps.prepare_release.outputs.image_tag_versions }}"
|
|
|
|
IMAGE_NAME="${{ steps.prepare_release.outputs.image_name }}"
|
|
|
|
else
|
|
|
|
exit 1
|
2020-09-07 23:16:26 +02:00
|
|
|
fi
|
|
|
|
|
2021-02-15 16:18:59 +01:00
|
|
|
echo ::set-output name=image_tag_versions::${TAGS}
|
|
|
|
echo ::set-output name=image_name::${IMAGE_NAME}
|
2020-09-07 23:16:26 +02:00
|
|
|
|
2021-02-15 16:18:59 +01: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 }}
|
|
|
|
tags: ${{ steps.prepare_tags.outputs.image_tag_versions }}
|
|
|
|
|
|
|
|
-
|
|
|
|
name: Image digest
|
2021-03-17 17:05:27 +01:00
|
|
|
run: echo ${{ steps.docker_build.outputs.digest }}
|