Prepare universal workflow

This commit is contained in:
Alexey Pustovalov 2024-02-10 00:00:45 +09:00
parent 1fe35722ac
commit 4a19042dc8

View File

@ -94,7 +94,7 @@ jobs:
run: |
component_list='["agent","agent2"]'
echo "::group::Operating System List"
echo "::group::Zabbix Component List"
echo "$component_list"
echo "::endgroup::"
@ -173,6 +173,11 @@ jobs:
MATRIX_FILE: ${{ env.MATRIX_FILE }}
run: |
$os_tag=$(Get-Content -Path $Env:MATRIX_FILE | ConvertFrom-Json).'os-windows'."$Env:MATRIX_OS"
echo "::group::Base Windows OS tag"
echo "$os_tag"
echo "::endgroup::"
echo "os_tag=$os_tag" >> $Env:GITHUB_OUTPUT
- name: Generate tags
@ -205,6 +210,13 @@ jobs:
AUTO_PUSH_IMAGES: ${{ env.AUTO_PUSH_IMAGES }}
SHA_SHORT: ${{ needs.init_build.outputs.sha_short }}
run: |
echo "::group::Docker version"
docker version
echo "::endgroup::"
echo "::group::Docker info"
docker info
echo "::endgroup::"
$context="$Env:DOCKERFILES_DIRECTORY\$Env:BASE_BUILD_NAME\windows\"
$dockerfile= $context + 'Dockerfile.' + $Env:MATRIX_COMPONENT
$base_os_image= $Env:BASE_BUILD_IMAGE + ':' + $Env:BASE_OS_TAG
@ -214,12 +226,21 @@ jobs:
$tags_array=$( "$Env:TAGS".Split("`n") )
$tags=$( $tags_array | Foreach-Object { "--tag=$_" } )
docker version
docker info
echo "docker build --label org.opencontainers.image.revision=$Env:LABEL_REVISION --label org.opencontainers.image.created=$Env:LABEL_CREATED --build-arg=BUILD_BASE_IMAGE=$base_os_image --file=$dockerfile $tags $context"
echo "::group::Image tags"
echo "$Env:TAGS"
echo "::endgroup::"
echo "::group::Pull base image"
docker pull $base_os_image
echo "::endgroup::"
echo "::group::Build Image"
Write-Host @"docker build --label org.opencontainers.image.revision=$Env:LABEL_REVISION
--label org.opencontainers.image.created=$Env:LABEL_CREATED
--build-arg=BUILD_BASE_IMAGE=$base_os_image
--file=$dockerfile
$tags
$context
"@
docker build --label org.opencontainers.image.revision=$Env:LABEL_REVISION `
--label org.opencontainers.image.created=$Env:LABEL_CREATED `
@ -228,7 +249,9 @@ jobs:
$tags `
$context
if (-not $?) {throw "Failed"}
echo "::endgroup::"
echo "::group::Publish Image"
if ( $Env:AUTO_PUSH_IMAGES -eq 'true' ) {
Foreach ($tag in $tags_array) {
echo "docker image push $tag"
@ -238,13 +261,18 @@ jobs:
$digest=$(docker inspect $tags_array[0] --format "{{ index .RepoDigests 0}}").Split('@')[-1]
if (-not $?) {throw "Failed"}
echo "Image digest got from RepoDigests"
}
else {
$digest=$(docker inspect $tags_array[0] --format "{{ index .Id}}")
if (-not $?) {throw "Failed"}
echo "Image digest got from Id"
}
echo "::endgroup::"
echo "::group::Digest"
echo "$digest"
echo "::endgroup::"
echo "digest=$digest" >> $Env:GITHUB_OUTPUT
- name: Sign the images with GitHub OIDC Token