mirror of
https://github.com/zabbix/zabbix-docker.git
synced 2025-01-08 14:49:46 +01:00
Added Azure registry build action
This commit is contained in:
parent
7763e4e30a
commit
5d24043d8e
126
.github/workflows/Azure.yml
vendored
126
.github/workflows/Azure.yml
vendored
@ -8,6 +8,7 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- '5.0'
|
- '5.0'
|
||||||
- '5.4'
|
- '5.4'
|
||||||
|
- 'trunk'
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '.env*'
|
- '.env*'
|
||||||
- 'docker-compose*.yaml'
|
- 'docker-compose*.yaml'
|
||||||
@ -21,9 +22,6 @@ defaults:
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
timeout-minutes: 70
|
timeout-minutes: 70
|
||||||
env:
|
|
||||||
LATEST_BRANCH: "${{ github.event.repository.default_branch }}"
|
|
||||||
DOCKER_REPOSITORY: "zabbix"
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@ -47,49 +45,97 @@ jobs:
|
|||||||
|
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
-
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Detect branch name
|
-
|
||||||
id: extract_branch
|
name: Set up QEMU
|
||||||
shell: bash
|
uses: docker/setup-qemu-action@v1
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
-
|
||||||
|
name: Login to Azure Container Registry
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry: ${{ secrets.azure_registry }}.azurecr.io
|
||||||
|
username: ${{ secrets.AZURE_USERNAME }}
|
||||||
|
password: ${{ secrets.AZURE_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Prepare platform list
|
||||||
|
id: platform
|
||||||
run: |
|
run: |
|
||||||
|
DOCKER_PLATFORM="linux/amd64,linux/arm64"
|
||||||
|
echo ::set-output name=list::${DOCKER_PLATFORM}
|
||||||
|
|
||||||
|
- name: Prepare environment (push)
|
||||||
|
if: github.event_name == 'push'
|
||||||
|
id: prepare_push
|
||||||
|
run: |
|
||||||
|
TAGS_ARRAY=()
|
||||||
|
|
||||||
|
IMAGE_NAME="${{ secrets.azure_registry }}.azurecr.io/${{ matrix.os }}/zabbix-${{ matrix.build }}"
|
||||||
GIT_BRANCH="${GITHUB_REF##*/}"
|
GIT_BRANCH="${GITHUB_REF##*/}"
|
||||||
GIT_BRANCH=`expr "${GIT_BRANCH}" : '\([0-9]*\.[0-9]*\).*'`
|
GIT_BRANCH=`expr "${GIT_BRANCH}" : '\([0-9]*\.[0-9]*\).*'`
|
||||||
echo ::set-output name=branch::${GIT_BRANCH}
|
|
||||||
|
|
||||||
- name: Detect Zabbix version
|
echo "::debug::Branch - ${GIT_BRANCH}"
|
||||||
id: extract_release
|
|
||||||
shell: bash
|
|
||||||
run: echo "##[set-output name=release_version;]$(echo ${GITHUB_REF##*/})"
|
|
||||||
|
|
||||||
- name: ACR build (push)
|
TAGS_ARRAY+=("$IMAGE_NAME:${GIT_BRANCH}")
|
||||||
if: github.event_name == 'push'
|
|
||||||
id: acr_push
|
|
||||||
uses: ams0/acr-task-github-action@v2
|
|
||||||
with:
|
|
||||||
service_principal: ${{ secrets.azure_service_principal }}
|
|
||||||
service_principal_password: ${{ secrets.azure_service_principal_password }}
|
|
||||||
tenant: ${{ secrets.azure_tenant }}
|
|
||||||
registry: ${{ secrets.azure_registry }}
|
|
||||||
repository: ${{ matrix.os }}
|
|
||||||
image: zabbix-${{ matrix.build }}
|
|
||||||
folder: ${{ matrix.build }}/${{ matrix.os }}
|
|
||||||
branch: ${{ steps.extract_branch.outputs.branch }}
|
|
||||||
tag: v${{ steps.extract_branch.outputs.branch }}
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
|
|
||||||
- name: ACR build (release)
|
TAGS=$(printf -- "%s, " "${TAGS_ARRAY[@]}")
|
||||||
|
|
||||||
|
echo "::debug::Tags - ${TAGS}"
|
||||||
|
|
||||||
|
echo ::set-output name=image_name::${IMAGE_NAME}
|
||||||
|
echo ::set-output name=image_tag_versions::$(printf -- "%s," "${TAGS_ARRAY[@]}")
|
||||||
|
|
||||||
|
- name: Prepare environment (release)
|
||||||
if: github.event_name == 'release' && github.event.action == 'published'
|
if: github.event_name == 'release' && github.event.action == 'published'
|
||||||
id: acr_release
|
id: prepare_release
|
||||||
uses: ams0/acr-task-github-action@v2
|
run: |
|
||||||
|
TAGS_ARRAY=()
|
||||||
|
|
||||||
|
IMAGE_NAME="${{ secrets.azure_registry }}.azurecr.io/${{ matrix.os }}/zabbix-${{ matrix.build }}"
|
||||||
|
RELEASE_VERSION=${GITHUB_REF##*/}
|
||||||
|
GIT_BRANCH="${GITHUB_REF##*/}"
|
||||||
|
GIT_BRANCH=`expr "${GIT_BRANCH}" : '\([0-9]*\.[0-9]*\).*'`
|
||||||
|
|
||||||
|
echo "::debug::Release version ${RELEASE_VERSION}. Branch ${GIT_BRANCH}"
|
||||||
|
|
||||||
|
TAGS_ARRAY+=("$IMAGE_NAME:${RELEASE_VERSION}")
|
||||||
|
|
||||||
|
TAGS=$(printf -- "--tag %s " "${TAGS_ARRAY[@]}")
|
||||||
|
|
||||||
|
echo ::set-output name=image_name::${IMAGE_NAME}
|
||||||
|
echo ::set-output name=image_tag_versions::$(printf -- ",%s" "${TAGS_ARRAY[@]}")
|
||||||
|
|
||||||
|
- name: Prepare tags
|
||||||
|
id: prepare_tags
|
||||||
|
run: |
|
||||||
|
if [ ! -z "${{ steps.prepare_push.outputs.image_tag_versions }}" ]; then
|
||||||
|
TAGS="${{ steps.prepare_push.outputs.image_tag_versions }}"
|
||||||
|
IMAGE_NAME="${{ steps.prepare_push.outputs.image_name }}"
|
||||||
|
elif [ ! -z "${{ steps.prepare_release.outputs.image_tag_versions }}" ]; then
|
||||||
|
TAGS="${{ steps.prepare_release.outputs.image_tag_versions }}"
|
||||||
|
IMAGE_NAME="${{ steps.prepare_release.outputs.image_name }}"
|
||||||
|
else
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ::set-output name=image_tag_versions::${TAGS}
|
||||||
|
echo ::set-output name=image_name::${IMAGE_NAME}
|
||||||
|
|
||||||
|
-
|
||||||
|
name: Build and push
|
||||||
|
id: docker_build
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
service_principal: ${{ secrets.azure_service_principal }}
|
context: ./${{ matrix.build }}/${{ matrix.os }}
|
||||||
service_principal_password: ${{ secrets.azure_service_principal_password }}
|
file: ./${{ matrix.build }}/${{ matrix.os }}/Dockerfile
|
||||||
tenant: ${{ secrets.azure_tenant }}
|
platforms: ${{ steps.platform.outputs.list }}
|
||||||
registry: ${{ secrets.azure_registry }}
|
push: ${{ secrets.AUTO_PUSH_IMAGES }}
|
||||||
repository: ${{ matrix.os }}
|
tags: ${{ steps.prepare.outputs.image_tag_versions }}
|
||||||
image: zabbix-${{ matrix.build }}
|
|
||||||
folder: ${{ matrix.build }}/${{ matrix.os }}
|
-
|
||||||
branch: ${{ steps.extract_branch.outputs.branch }}
|
name: Image digest
|
||||||
tag: v${{ steps.extract_release.outputs.release_version}}
|
run: echo ${{ steps.docker_build.outputs.digest }}
|
||||||
dockerfile: Dockerfile
|
|
||||||
|
Loading…
Reference in New Issue
Block a user