mirror of
https://github.com/zabbix/zabbix-docker.git
synced 2025-01-05 21:29:17 +01:00
Added Azure registry build action
This commit is contained in:
parent
7763e4e30a
commit
5d24043d8e
130
.github/workflows/Azure.yml
vendored
130
.github/workflows/Azure.yml
vendored
@ -8,6 +8,7 @@ on:
|
||||
branches:
|
||||
- '5.0'
|
||||
- '5.4'
|
||||
- 'trunk'
|
||||
paths-ignore:
|
||||
- '.env*'
|
||||
- 'docker-compose*.yaml'
|
||||
@ -21,9 +22,6 @@ defaults:
|
||||
jobs:
|
||||
build:
|
||||
timeout-minutes: 70
|
||||
env:
|
||||
LATEST_BRANCH: "${{ github.event.repository.default_branch }}"
|
||||
DOCKER_REPOSITORY: "zabbix"
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@ -47,49 +45,97 @@ jobs:
|
||||
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
-
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Detect branch name
|
||||
id: extract_branch
|
||||
shell: bash
|
||||
-
|
||||
name: Set up QEMU
|
||||
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: |
|
||||
GIT_BRANCH="${GITHUB_REF##*/}"
|
||||
GIT_BRANCH=`expr "${GIT_BRANCH}" : '\([0-9]*\.[0-9]*\).*'`
|
||||
echo ::set-output name=branch::${GIT_BRANCH}
|
||||
DOCKER_PLATFORM="linux/amd64,linux/arm64"
|
||||
echo ::set-output name=list::${DOCKER_PLATFORM}
|
||||
|
||||
- name: Detect Zabbix version
|
||||
id: extract_release
|
||||
shell: bash
|
||||
run: echo "##[set-output name=release_version;]$(echo ${GITHUB_REF##*/})"
|
||||
|
||||
- name: ACR build (push)
|
||||
- name: Prepare environment (push)
|
||||
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
|
||||
id: prepare_push
|
||||
run: |
|
||||
TAGS_ARRAY=()
|
||||
|
||||
- name: ACR build (release)
|
||||
IMAGE_NAME="${{ secrets.azure_registry }}.azurecr.io/${{ matrix.os }}/zabbix-${{ matrix.build }}"
|
||||
GIT_BRANCH="${GITHUB_REF##*/}"
|
||||
GIT_BRANCH=`expr "${GIT_BRANCH}" : '\([0-9]*\.[0-9]*\).*'`
|
||||
|
||||
echo "::debug::Branch - ${GIT_BRANCH}"
|
||||
|
||||
TAGS_ARRAY+=("$IMAGE_NAME:${GIT_BRANCH}")
|
||||
|
||||
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'
|
||||
id: acr_release
|
||||
uses: ams0/acr-task-github-action@v2
|
||||
id: prepare_release
|
||||
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:
|
||||
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_release.outputs.release_version}}
|
||||
dockerfile: Dockerfile
|
||||
context: ./${{ matrix.build }}/${{ matrix.os }}
|
||||
file: ./${{ matrix.build }}/${{ matrix.os }}/Dockerfile
|
||||
platforms: ${{ steps.platform.outputs.list }}
|
||||
push: ${{ secrets.AUTO_PUSH_IMAGES }}
|
||||
tags: ${{ steps.prepare.outputs.image_tag_versions }}
|
||||
|
||||
-
|
||||
name: Image digest
|
||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
||||
|
Loading…
Reference in New Issue
Block a user