mirror of
https://github.com/zabbix/zabbix-docker.git
synced 2025-06-12 04:47:26 +02:00
Updated building images workflow
This commit is contained in:
parent
1f499f2d0e
commit
2c2f38a340
138
.github/workflows/images_build.yml
vendored
138
.github/workflows/images_build.yml
vendored
@ -28,7 +28,7 @@ permissions:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
TRUNK_ONLY_EVENT: ${{ contains(fromJSON('["schedule"]'), github.event_name) }}
|
TRUNK_ONLY_EVENT: ${{ contains(fromJSON('["schedule"]'), github.event_name) }}
|
||||||
AUTO_PUSH_IMAGES: ${{ vars.AUTO_PUSH_IMAGES }}
|
AUTO_PUSH_IMAGES: ${{ ! contains(fromJSON('["workflow_dispatch"]'), github.event_name) && vars.AUTO_PUSH_IMAGES }}
|
||||||
|
|
||||||
DOCKER_REPOSITORY: ${{ vars.DOCKER_REPOSITORY }}
|
DOCKER_REPOSITORY: ${{ vars.DOCKER_REPOSITORY }}
|
||||||
LATEST_BRANCH: ${{ github.event.repository.default_branch }}
|
LATEST_BRANCH: ${{ github.event.repository.default_branch }}
|
||||||
@ -45,6 +45,9 @@ env:
|
|||||||
OIDC_ISSUER: "https://token.actions.githubusercontent.com"
|
OIDC_ISSUER: "https://token.actions.githubusercontent.com"
|
||||||
IDENTITY_REGEX: "https://github.com/zabbix/zabbix-docker/.github/"
|
IDENTITY_REGEX: "https://github.com/zabbix/zabbix-docker/.github/"
|
||||||
|
|
||||||
|
DOCKER_REGISTRY_TEST: "ghcr.io"
|
||||||
|
DOCKER_REPOSITORY_TEST: "zabbix"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
init_build:
|
init_build:
|
||||||
name: Initialize build
|
name: Initialize build
|
||||||
@ -65,7 +68,9 @@ jobs:
|
|||||||
disable-sudo: true
|
disable-sudo: true
|
||||||
egress-policy: block
|
egress-policy: block
|
||||||
allowed-endpoints: >
|
allowed-endpoints: >
|
||||||
|
api.github.com:443
|
||||||
github.com:443
|
github.com:443
|
||||||
|
objects.githubusercontent.com:443
|
||||||
|
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||||
@ -165,6 +170,7 @@ jobs:
|
|||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
id-token: write
|
id-token: write
|
||||||
|
packages: write
|
||||||
steps:
|
steps:
|
||||||
- name: Block egress traffic
|
- name: Block egress traffic
|
||||||
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
|
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
|
||||||
@ -195,6 +201,7 @@ jobs:
|
|||||||
ftpmirror.your.org:80
|
ftpmirror.your.org:80
|
||||||
fulcio.sigstore.dev:443
|
fulcio.sigstore.dev:443
|
||||||
github.com:443
|
github.com:443
|
||||||
|
ghcr.io:443
|
||||||
iad.mirror.rackspace.com:443
|
iad.mirror.rackspace.com:443
|
||||||
iad.mirror.rackspace.com:80
|
iad.mirror.rackspace.com:80
|
||||||
index.docker.io:443
|
index.docker.io:443
|
||||||
@ -253,6 +260,7 @@ jobs:
|
|||||||
uvermont.mm.fcix.net:443
|
uvermont.mm.fcix.net:443
|
||||||
yum.oracle.com:443
|
yum.oracle.com:443
|
||||||
ziply.mm.fcix.net:443
|
ziply.mm.fcix.net:443
|
||||||
|
pkg-containers.githubusercontent.com:443
|
||||||
|
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||||
@ -261,11 +269,13 @@ jobs:
|
|||||||
fetch-depth: 1
|
fetch-depth: 1
|
||||||
|
|
||||||
- name: Install cosign
|
- name: Install cosign
|
||||||
|
if: ${{ env.AUTO_PUSH_IMAGES == 'true' }}
|
||||||
uses: sigstore/cosign-installer@e1523de7571e31dbe865fd2e80c5c7c23ae71eb4
|
uses: sigstore/cosign-installer@e1523de7571e31dbe865fd2e80c5c7c23ae71eb4
|
||||||
with:
|
with:
|
||||||
cosign-release: 'v2.2.3'
|
cosign-release: 'v2.2.3'
|
||||||
|
|
||||||
- name: Check cosign version
|
- name: Check cosign version
|
||||||
|
if: ${{ env.AUTO_PUSH_IMAGES == 'true' }}
|
||||||
run: cosign version
|
run: cosign version
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
@ -279,12 +289,6 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
driver-opts: image=moby/buildkit:master
|
driver-opts: image=moby/buildkit:master
|
||||||
|
|
||||||
- name: Login to DockerHub
|
|
||||||
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
||||||
|
|
||||||
- name: Prepare Platform list
|
- name: Prepare Platform list
|
||||||
id: platform
|
id: platform
|
||||||
env:
|
env:
|
||||||
@ -304,16 +308,18 @@ jobs:
|
|||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
|
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
|
||||||
with:
|
with:
|
||||||
images: ${{ env.DOCKER_REPOSITORY }}/${{ env.IMAGES_PREFIX }}${{ env.BASE_BUILD_NAME }}
|
images: |
|
||||||
|
${{ format('{0}/{1}/{2}{3}', env.DOCKER_REGISTRY_TEST, env.DOCKER_REPOSITORY_TEST, env.IMAGES_PREFIX, env.BASE_BUILD_NAME ) }},enable=${{ env.AUTO_PUSH_IMAGES != 'true' }}
|
||||||
|
${{ format('{0}/{1}{2}', env.DOCKER_REPOSITORY, env.IMAGES_PREFIX, env.BASE_BUILD_NAME ) }},enable=${{ env.AUTO_PUSH_IMAGES == 'true' }}
|
||||||
context: ${{ env.TRUNK_ONLY_EVENT == 'true' && 'git' || '' }}
|
context: ${{ env.TRUNK_ONLY_EVENT == 'true' && 'git' || '' }}
|
||||||
tags: |
|
tags: |
|
||||||
type=semver,enable=${{ needs.init_build.outputs.current_branch != 'trunk' }},pattern={{version}},prefix=${{ matrix.os }}-
|
type=semver,enable=${{ needs.init_build.outputs.current_branch != 'trunk' }},pattern={{version}},prefix=${{ matrix.os }}-
|
||||||
type=semver,enable=${{ needs.init_build.outputs.current_branch != 'trunk' }},pattern={{version}},suffix=-${{ matrix.os }}
|
type=semver,enable=${{ needs.init_build.outputs.current_branch != 'trunk' }},pattern={{version}},suffix=-${{ matrix.os }}
|
||||||
type=ref,enable=${{ needs.init_build.outputs.current_branch != 'trunk' }},event=branch,prefix=${{ matrix.os }}-,suffix=-latest
|
type=ref,enable=${{ needs.init_build.outputs.current_branch != 'trunk' && !contains(fromJSON('["workflow_dispatch"]'), github.event_name) }},event=branch,prefix=${{ matrix.os }}-,suffix=-latest
|
||||||
type=ref,enable=${{ needs.init_build.outputs.current_branch != 'trunk' }},event=branch,suffix=-${{ matrix.os }}-latest
|
type=ref,enable=${{ needs.init_build.outputs.current_branch != 'trunk' && !contains(fromJSON('["workflow_dispatch"]'), github.event_name) }},event=branch,suffix=-${{ matrix.os }}-latest
|
||||||
type=raw,enable=${{ (needs.init_build.outputs.current_branch != 'trunk') && (needs.init_build.outputs.is_default_branch == 'true') }},value=${{matrix.os}}-latest
|
type=raw,enable=${{ (needs.init_build.outputs.current_branch != 'trunk') && (needs.init_build.outputs.is_default_branch == 'true') }},value=${{matrix.os}}-latest
|
||||||
type=ref,enable=${{ needs.init_build.outputs.current_branch == 'trunk' }},event=branch,prefix=${{ matrix.os }}-
|
type=ref,enable=${{ needs.init_build.outputs.current_branch == 'trunk' }},event=branch,prefix=${{ matrix.os }}-
|
||||||
type=ref,enable=${{ needs.init_build.outputs.current_branch == 'trunk' }},event=branch,suffix=-${{ matrix.os }}
|
type=ref,enable=${{ needs.init_build.outputs.current_branch == 'trunk' || contains(fromJSON('["workflow_dispatch"]'), github.event_name) }},event=branch,suffix=-${{ matrix.os }}
|
||||||
flavor: |
|
flavor: |
|
||||||
latest=${{ (matrix.os == 'alpine') && (!contains(fromJSON('["workflow_dispatch"]'), github.event_name)) && ( needs.init_build.outputs.is_default_branch == 'true' ) }}
|
latest=${{ (matrix.os == 'alpine') && (!contains(fromJSON('["workflow_dispatch"]'), github.event_name)) && ( needs.init_build.outputs.is_default_branch == 'true' ) }}
|
||||||
|
|
||||||
@ -368,10 +374,10 @@ jobs:
|
|||||||
id: docker_build
|
id: docker_build
|
||||||
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
|
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
|
||||||
with:
|
with:
|
||||||
context: ${{ env.DOCKERFILES_DIRECTORY }}/${{ env.BASE_BUILD_NAME }}/${{ matrix.os }}
|
context: ${{ format('{0}/{1}/{2}', env.DOCKERFILES_DIRECTORY, env.BASE_BUILD_NAME, matrix.os) }}
|
||||||
file: ${{ env.DOCKERFILES_DIRECTORY }}/${{ env.BASE_BUILD_NAME }}/${{ matrix.os }}/Dockerfile
|
file: ${{ format('{0}/{1}/{2}/Dockerfile', env.DOCKERFILES_DIRECTORY, env.BASE_BUILD_NAME, matrix.os) }}
|
||||||
platforms: ${{ steps.platform.outputs.list }}
|
platforms: ${{ steps.platform.outputs.list }}
|
||||||
push: ${{ env.AUTO_PUSH_IMAGES }}
|
push: true
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: |
|
labels: |
|
||||||
org.opencontainers.image.revision=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
|
org.opencontainers.image.revision=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
|
||||||
@ -380,6 +386,7 @@ jobs:
|
|||||||
cache-to: ${{ steps.cache_data.outputs.cache_to }}
|
cache-to: ${{ steps.cache_data.outputs.cache_to }}
|
||||||
|
|
||||||
- name: Sign the images with GitHub OIDC Token
|
- name: Sign the images with GitHub OIDC Token
|
||||||
|
if: ${{ env.AUTO_PUSH_IMAGES == 'true' }}
|
||||||
env:
|
env:
|
||||||
DIGEST: ${{ steps.docker_build.outputs.digest }}
|
DIGEST: ${{ steps.docker_build.outputs.digest }}
|
||||||
TAGS: ${{ steps.meta.outputs.tags }}
|
TAGS: ${{ steps.meta.outputs.tags }}
|
||||||
@ -403,14 +410,14 @@ jobs:
|
|||||||
CACHE_FILE_NAME: ${{ env.BASE_CACHE_FILE_NAME }}
|
CACHE_FILE_NAME: ${{ env.BASE_CACHE_FILE_NAME }}
|
||||||
METADATA: ${{ steps.docker_build.outputs.metadata }}
|
METADATA: ${{ steps.docker_build.outputs.metadata }}
|
||||||
run: |
|
run: |
|
||||||
echo "::group::Image digest"
|
echo "::group::Image metadata"
|
||||||
echo "$DIGEST"
|
echo "${METADATA}"
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
echo "::group::Cache file name"
|
echo "::group::Cache file name"
|
||||||
echo "$CACHE_FILE_NAME"
|
echo "${CACHE_FILE_NAME}"
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
|
|
||||||
echo "$DIGEST" > "$CACHE_FILE_NAME"
|
echo "${METADATA}" > "$CACHE_FILE_NAME"
|
||||||
|
|
||||||
- name: Cache image metadata
|
- name: Cache image metadata
|
||||||
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
|
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
|
||||||
@ -427,11 +434,11 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
build: ${{ fromJson(needs.init_build.outputs.database) }}
|
build: ${{ fromJson(needs.init_build.outputs.database) }}
|
||||||
os: ${{ fromJson(needs.init_build.outputs.os) }}
|
os: ${{ fromJson(needs.init_build.outputs.os) }}
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
id-token: write
|
id-token: write
|
||||||
|
packages: write
|
||||||
steps:
|
steps:
|
||||||
- name: Block egress traffic
|
- name: Block egress traffic
|
||||||
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
|
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
|
||||||
@ -448,6 +455,7 @@ jobs:
|
|||||||
golang.org:443
|
golang.org:443
|
||||||
google.golang.org:443
|
google.golang.org:443
|
||||||
gopkg.in:443
|
gopkg.in:443
|
||||||
|
ghcr.io:443
|
||||||
index.docker.io:443
|
index.docker.io:443
|
||||||
noto-website.storage.googleapis.com:443
|
noto-website.storage.googleapis.com:443
|
||||||
production.cloudflare.docker.com:443
|
production.cloudflare.docker.com:443
|
||||||
@ -459,6 +467,7 @@ jobs:
|
|||||||
objects.githubusercontent.com:443
|
objects.githubusercontent.com:443
|
||||||
tuf-repo-cdn.sigstore.dev:443
|
tuf-repo-cdn.sigstore.dev:443
|
||||||
rekor.sigstore.dev:443
|
rekor.sigstore.dev:443
|
||||||
|
pkg-containers.githubusercontent.com:443
|
||||||
|
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||||
@ -467,11 +476,13 @@ jobs:
|
|||||||
fetch-depth: 1
|
fetch-depth: 1
|
||||||
|
|
||||||
- name: Install cosign
|
- name: Install cosign
|
||||||
|
if: ${{ env.AUTO_PUSH_IMAGES == 'true' }}
|
||||||
uses: sigstore/cosign-installer@e1523de7571e31dbe865fd2e80c5c7c23ae71eb4
|
uses: sigstore/cosign-installer@e1523de7571e31dbe865fd2e80c5c7c23ae71eb4
|
||||||
with:
|
with:
|
||||||
cosign-release: 'v2.2.3'
|
cosign-release: 'v2.2.3'
|
||||||
|
|
||||||
- name: Check cosign version
|
- name: Check cosign version
|
||||||
|
if: ${{ env.AUTO_PUSH_IMAGES == 'true' }}
|
||||||
run: cosign version
|
run: cosign version
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
@ -485,12 +496,6 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
driver-opts: image=moby/buildkit:master
|
driver-opts: image=moby/buildkit:master
|
||||||
|
|
||||||
- name: Login to DockerHub
|
|
||||||
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
||||||
|
|
||||||
- name: Prepare Platform list
|
- name: Prepare Platform list
|
||||||
id: platform
|
id: platform
|
||||||
env:
|
env:
|
||||||
@ -510,18 +515,20 @@ jobs:
|
|||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
|
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
|
||||||
with:
|
with:
|
||||||
images: ${{ env.DOCKER_REPOSITORY }}/${{ env.IMAGES_PREFIX }}${{ matrix.build }}
|
images: |
|
||||||
|
${{ format('{0}/{1}/{2}{3}', env.DOCKER_REGISTRY_TEST, env.DOCKER_REPOSITORY_TEST, env.IMAGES_PREFIX, matrix.build ) }},enable=${{ env.AUTO_PUSH_IMAGES != 'true' }}
|
||||||
|
${{ format('{0}/{1}{2}', env.DOCKER_REPOSITORY, env.IMAGES_PREFIX, matrix.build ) }},enable=${{ env.AUTO_PUSH_IMAGES == 'true' }}
|
||||||
context: ${{ env.TRUNK_ONLY_EVENT == 'true' && 'git' || '' }}
|
context: ${{ env.TRUNK_ONLY_EVENT == 'true' && 'git' || '' }}
|
||||||
tags: |
|
tags: |
|
||||||
type=semver,enable=${{ needs.init_build.outputs.current_branch != 'trunk' }},pattern={{version}},prefix=${{ matrix.os }}-
|
type=semver,enable=${{ needs.init_build.outputs.current_branch != 'trunk' }},pattern={{version}},prefix=${{ matrix.os }}-
|
||||||
type=semver,enable=${{ needs.init_build.outputs.current_branch != 'trunk' }},pattern={{version}},suffix=-${{ matrix.os }}
|
type=semver,enable=${{ needs.init_build.outputs.current_branch != 'trunk' }},pattern={{version}},suffix=-${{ matrix.os }}
|
||||||
type=ref,enable=${{ needs.init_build.outputs.current_branch != 'trunk' }},event=branch,prefix=${{ matrix.os }}-,suffix=-latest
|
type=ref,enable=${{ needs.init_build.outputs.current_branch != 'trunk' && (!contains(fromJSON('["workflow_dispatch"]'), github.event_name)) }},event=branch,prefix=${{ matrix.os }}-,suffix=-latest
|
||||||
type=ref,enable=${{ needs.init_build.outputs.current_branch != 'trunk' }},event=branch,suffix=-${{ matrix.os }}-latest
|
type=ref,enable=${{ needs.init_build.outputs.current_branch != 'trunk' && (!contains(fromJSON('["workflow_dispatch"]'), github.event_name)) }},event=branch,suffix=-${{ matrix.os }}-latest
|
||||||
type=raw,enable=${{ (needs.init_build.outputs.current_branch != 'trunk') && (needs.init_build.outputs.is_default_branch == 'true') }},value=${{matrix.os}}-latest
|
type=raw,enable=${{ (needs.init_build.outputs.current_branch != 'trunk') && (needs.init_build.outputs.is_default_branch == 'true') }},value=${{matrix.os}}-latest
|
||||||
type=ref,enable=${{ needs.init_build.outputs.current_branch == 'trunk' }},event=branch,prefix=${{ matrix.os }}-
|
type=ref,enable=${{ needs.init_build.outputs.current_branch == 'trunk' }},event=branch,prefix=${{ matrix.os }}-
|
||||||
type=ref,enable=${{ needs.init_build.outputs.current_branch == 'trunk' }},event=branch,suffix=-${{ matrix.os }}
|
type=ref,enable=${{ needs.init_build.outputs.current_branch == 'trunk' || contains(fromJSON('["workflow_dispatch"]'), github.event_name) }},event=branch,suffix=-${{ matrix.os }}
|
||||||
flavor: |
|
flavor: |
|
||||||
latest=${{ (needs.init_build.outputs.current_branch != 'trunk') && (matrix.os == 'alpine') && ( needs.init_build.outputs.is_default_branch == 'true' ) }}
|
latest=${{ (matrix.os == 'alpine') && (!contains(fromJSON('["workflow_dispatch"]'), github.event_name)) && ( needs.init_build.outputs.is_default_branch == 'true' ) }}
|
||||||
|
|
||||||
- name: Download metadata of ${{ env.BASE_BUILD_NAME }}:${{ matrix.os }}
|
- name: Download metadata of ${{ env.BASE_BUILD_NAME }}:${{ matrix.os }}
|
||||||
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
|
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
|
||||||
@ -529,7 +536,7 @@ jobs:
|
|||||||
path: ${{ env.BASE_CACHE_FILE_NAME }}
|
path: ${{ env.BASE_CACHE_FILE_NAME }}
|
||||||
key: ${{ env.BASE_BUILD_NAME }}-${{ matrix.os }}-${{ github.run_id }}
|
key: ${{ env.BASE_BUILD_NAME }}-${{ matrix.os }}-${{ github.run_id }}
|
||||||
|
|
||||||
- name: Retrieve ${{ env.BASE_BUILD_NAME }}:${{ matrix.os }} SHA256 tag
|
- name: Process ${{ env.BASE_BUILD_NAME }}:${{ matrix.os }} image metadata
|
||||||
id: base_build
|
id: base_build
|
||||||
env:
|
env:
|
||||||
CACHE_FILE_NAME: ${{ env.BASE_CACHE_FILE_NAME }}
|
CACHE_FILE_NAME: ${{ env.BASE_CACHE_FILE_NAME }}
|
||||||
@ -544,6 +551,7 @@ jobs:
|
|||||||
echo "base_build_image=${IMAGE_NAME}@${IMAGE_DIGEST}" >> $GITHUB_OUTPUT
|
echo "base_build_image=${IMAGE_NAME}@${IMAGE_DIGEST}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Verify ${{ env.BASE_BUILD_NAME }}:${{ matrix.os }} cosign
|
- name: Verify ${{ env.BASE_BUILD_NAME }}:${{ matrix.os }} cosign
|
||||||
|
if: ${{ env.AUTO_PUSH_IMAGES == 'true' }}
|
||||||
env:
|
env:
|
||||||
BASE_IMAGE: ${{ steps.base_build.outputs.base_build_image }}
|
BASE_IMAGE: ${{ steps.base_build.outputs.base_build_image }}
|
||||||
OIDC_ISSUER: ${{ env.OIDC_ISSUER }}
|
OIDC_ISSUER: ${{ env.OIDC_ISSUER }}
|
||||||
@ -604,11 +612,11 @@ jobs:
|
|||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
- name: Login to DockerHub
|
- name: Login to ${{ env.DOCKER_REGISTRY_TEST }}
|
||||||
if: ${{ env.AUTO_PUSH_IMAGES != 'true' }}
|
if: ${{ env.AUTO_PUSH_IMAGES != 'true' }}
|
||||||
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
|
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ${{ env.DOCKER_REGISTRY_TEST }}
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
@ -616,10 +624,10 @@ jobs:
|
|||||||
id: docker_build
|
id: docker_build
|
||||||
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
|
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
|
||||||
with:
|
with:
|
||||||
context: ${{ env.DOCKERFILES_DIRECTORY }}/${{ matrix.build }}/${{ matrix.os }}
|
context: ${{ format('{0}/{1}/{2}/', env.DOCKERFILES_DIRECTORY, matrix.build, matrix.os) }}
|
||||||
file: ${{ env.DOCKERFILES_DIRECTORY }}/${{ matrix.build }}/${{ matrix.os }}/Dockerfile
|
file: ${{ format('{0}/{1}/{2}/Dockerfile', env.DOCKERFILES_DIRECTORY, matrix.build, matrix.os) }}
|
||||||
platforms: ${{ steps.platform.outputs.list }}
|
platforms: ${{ steps.platform.outputs.list }}
|
||||||
push: ${{ env.AUTO_PUSH_IMAGES }}
|
push: true
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
build-args: BUILD_BASE_IMAGE=${{ steps.base_build.outputs.base_build_image }}
|
build-args: BUILD_BASE_IMAGE=${{ steps.base_build.outputs.base_build_image }}
|
||||||
labels: |
|
labels: |
|
||||||
@ -627,6 +635,7 @@ jobs:
|
|||||||
org.opencontainers.image.created=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
|
org.opencontainers.image.created=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
|
||||||
|
|
||||||
- name: Sign the images with GitHub OIDC Token
|
- name: Sign the images with GitHub OIDC Token
|
||||||
|
if: ${{ env.AUTO_PUSH_IMAGES == 'true' }}
|
||||||
env:
|
env:
|
||||||
DIGEST: ${{ steps.docker_build.outputs.digest }}
|
DIGEST: ${{ steps.docker_build.outputs.digest }}
|
||||||
TAGS: ${{ steps.meta.outputs.tags }}
|
TAGS: ${{ steps.meta.outputs.tags }}
|
||||||
@ -650,13 +659,14 @@ jobs:
|
|||||||
CACHE_FILE_NAME: ${{ env.BUILD_CACHE_FILE_NAME }}
|
CACHE_FILE_NAME: ${{ env.BUILD_CACHE_FILE_NAME }}
|
||||||
METADATA: ${{ steps.docker_build.outputs.metadata }}
|
METADATA: ${{ steps.docker_build.outputs.metadata }}
|
||||||
run: |
|
run: |
|
||||||
echo "::group::Image digest"
|
echo "::group::Image metadata"
|
||||||
echo "$DIGEST"
|
echo "${METADATA}"
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
echo "::group::Cache file name"
|
echo "::group::Cache file name"
|
||||||
echo "$CACHE_FILE_NAME"
|
echo "${CACHE_FILE_NAME}"
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
echo "$DIGEST" > $CACHE_FILE_NAME
|
|
||||||
|
echo "${METADATA}" > "$CACHE_FILE_NAME"
|
||||||
|
|
||||||
- name: Cache image metadata
|
- name: Cache image metadata
|
||||||
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
|
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
|
||||||
@ -759,6 +769,7 @@ jobs:
|
|||||||
pubmirror1.math.uh.edu:443
|
pubmirror1.math.uh.edu:443
|
||||||
pubmirror3.math.uh.edu:80
|
pubmirror3.math.uh.edu:80
|
||||||
quay.io:443
|
quay.io:443
|
||||||
|
ghcr.io:443
|
||||||
registry-1.docker.io:443
|
registry-1.docker.io:443
|
||||||
repo.ialab.dsu.edu:80
|
repo.ialab.dsu.edu:80
|
||||||
repos.eggycrew.com:80
|
repos.eggycrew.com:80
|
||||||
@ -797,6 +808,7 @@ jobs:
|
|||||||
objects.githubusercontent.com:443
|
objects.githubusercontent.com:443
|
||||||
tuf-repo-cdn.sigstore.dev:443
|
tuf-repo-cdn.sigstore.dev:443
|
||||||
rekor.sigstore.dev:443
|
rekor.sigstore.dev:443
|
||||||
|
pkg-containers.githubusercontent.com:443
|
||||||
|
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||||
@ -873,7 +885,9 @@ jobs:
|
|||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
|
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
|
||||||
with:
|
with:
|
||||||
images: ${{ env.DOCKER_REPOSITORY }}/${{ env.IMAGES_PREFIX}}${{ matrix.build }}
|
images: |
|
||||||
|
${{ format('{0}/{1}/{2}{3}', env.DOCKER_REGISTRY_TEST, env.DOCKER_REPOSITORY_TEST, env.IMAGES_PREFIX, matrix.build ) }},enable=${{ env.AUTO_PUSH_IMAGES != 'true' }}
|
||||||
|
${{ format('{0}/{1}{2}', env.DOCKER_REPOSITORY, env.IMAGES_PREFIX, matrix.build ) }},enable=${{ env.AUTO_PUSH_IMAGES == 'true' }}
|
||||||
context: ${{ env.TRUNK_ONLY_EVENT == 'true' && 'git' || '' }}
|
context: ${{ env.TRUNK_ONLY_EVENT == 'true' && 'git' || '' }}
|
||||||
tags: |
|
tags: |
|
||||||
type=semver,enable=${{ needs.init_build.outputs.current_branch != 'trunk' }},pattern={{version}},prefix=${{ matrix.os }}-
|
type=semver,enable=${{ needs.init_build.outputs.current_branch != 'trunk' }},pattern={{version}},prefix=${{ matrix.os }}-
|
||||||
@ -882,9 +896,9 @@ jobs:
|
|||||||
type=ref,enable=${{ needs.init_build.outputs.current_branch != 'trunk' && !contains(fromJSON('["workflow_dispatch"]'), github.event_name) }},event=branch,suffix=-${{ matrix.os }}-latest
|
type=ref,enable=${{ needs.init_build.outputs.current_branch != 'trunk' && !contains(fromJSON('["workflow_dispatch"]'), github.event_name) }},event=branch,suffix=-${{ matrix.os }}-latest
|
||||||
type=raw,enable=${{ (needs.init_build.outputs.current_branch != 'trunk') && (needs.init_build.outputs.is_default_branch == 'true') }},value=${{matrix.os}}-latest
|
type=raw,enable=${{ (needs.init_build.outputs.current_branch != 'trunk') && (needs.init_build.outputs.is_default_branch == 'true') }},value=${{matrix.os}}-latest
|
||||||
type=ref,enable=${{ needs.init_build.outputs.current_branch == 'trunk' }},event=branch,prefix=${{ matrix.os }}-
|
type=ref,enable=${{ needs.init_build.outputs.current_branch == 'trunk' }},event=branch,prefix=${{ matrix.os }}-
|
||||||
type=ref,enable=${{ needs.init_build.outputs.current_branch == 'trunk' }},event=branch,suffix=-${{ matrix.os }}
|
type=ref,enable=${{ needs.init_build.outputs.current_branch == 'trunk' || contains(fromJSON('["workflow_dispatch"]'), github.event_name) }},event=branch,suffix=-${{ matrix.os }}
|
||||||
flavor: |
|
flavor: |
|
||||||
latest=${{ (needs.init_build.outputs.current_branch != 'trunk') && (matrix.os == 'alpine') && ( needs.init_build.outputs.is_default_branch == 'true' ) }}
|
latest=${{ (matrix.os == 'alpine') && (!contains(fromJSON('["workflow_dispatch"]'), github.event_name)) && ( needs.init_build.outputs.is_default_branch == 'true' ) }}
|
||||||
|
|
||||||
- name: Download metadata of ${{ steps.build_base_image.outputs.build_base }}:${{ matrix.os }}
|
- name: Download metadata of ${{ steps.build_base_image.outputs.build_base }}:${{ matrix.os }}
|
||||||
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
|
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
|
||||||
@ -899,19 +913,17 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
CACHE_FILE_NAME: ${{ env.BUILD_CACHE_FILE_NAME }}
|
CACHE_FILE_NAME: ${{ env.BUILD_CACHE_FILE_NAME }}
|
||||||
run: |
|
run: |
|
||||||
BASE_TAG=$(cat "${BUILD_BASE}_${MATRIX_OS}")
|
echo "::group::Base build image metadata"
|
||||||
BUILD_BASE_IMAGE=${DOCKER_REPOSITORY}/${IMAGES_PREFIX}${BUILD_BASE}@${BASE_TAG}
|
cat "${CACHE_FILE_NAME}"
|
||||||
|
|
||||||
echo "::group::Base build image information"
|
|
||||||
echo "base_tag=${BASE_TAG}"
|
|
||||||
echo "base_build_image=${BUILD_BASE_IMAGE}"
|
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
|
|
||||||
echo "base_tag=${BASE_TAG}" >> $GITHUB_OUTPUT
|
IMAGE_DIGEST=$(jq -r '."containerimage.digest"' "${CACHE_FILE_NAME}")
|
||||||
echo "base_build_image=${BUILD_BASE_IMAGE}" >> $GITHUB_OUTPUT
|
IMAGE_NAME=$(jq -r '."image.name"' "${CACHE_FILE_NAME}" | cut -d: -f1)
|
||||||
|
|
||||||
|
echo "base_build_image=${IMAGE_NAME}@${IMAGE_DIGEST}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Verify ${{ steps.build_base_image.outputs.build_base }}:${{ matrix.os }} cosign
|
- name: Verify ${{ steps.build_base_image.outputs.build_base }}:${{ matrix.os }} cosign
|
||||||
if: ${{ matrix.build != 'snmptraps' }}
|
if: ${{ matrix.build != 'snmptraps' && env.AUTO_PUSH_IMAGES == 'true' }}
|
||||||
env:
|
env:
|
||||||
BASE_IMAGE: ${{ steps.base_build.outputs.base_build_image }}
|
BASE_IMAGE: ${{ steps.base_build.outputs.base_build_image }}
|
||||||
OIDC_ISSUER: ${{ env.OIDC_ISSUER }}
|
OIDC_ISSUER: ${{ env.OIDC_ISSUER }}
|
||||||
@ -936,10 +948,8 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
BASE_IMAGE_TAG: ${{ steps.base_build.outputs.base_build_image }}
|
BASE_IMAGE_TAG: ${{ steps.base_build.outputs.base_build_image }}
|
||||||
run: |
|
run: |
|
||||||
cache_images=""
|
cache_from=()
|
||||||
if [[ ! -z "$BASE_IMAGE_TAG" ]]; then
|
cache_to=()
|
||||||
cache_images="type=gha,scope=$BASE_IMAGE_TAG"$'\n'"type=registry,ref=$BASE_IMAGE_TAG"
|
|
||||||
fi
|
|
||||||
|
|
||||||
cache_from+=("type=registry,ref=${BASE_IMAGE_TAG}")
|
cache_from+=("type=registry,ref=${BASE_IMAGE_TAG}")
|
||||||
|
|
||||||
@ -947,7 +957,11 @@ jobs:
|
|||||||
echo "${cache_from[*]}"
|
echo "${cache_from[*]}"
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
|
|
||||||
echo "cache_from=$cache_images" >> $GITHUB_OUTPUT
|
cache_from=$(printf '%s\n' "${cache_from[@]}")
|
||||||
|
|
||||||
|
echo 'cache_from<<EOF' >> "$GITHUB_OUTPUT"
|
||||||
|
echo "$cache_from" >> "$GITHUB_OUTPUT"
|
||||||
|
echo 'EOF' >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Login to DockerHub
|
- name: Login to DockerHub
|
||||||
if: ${{ env.AUTO_PUSH_IMAGES == 'true' }}
|
if: ${{ env.AUTO_PUSH_IMAGES == 'true' }}
|
||||||
@ -963,15 +977,15 @@ jobs:
|
|||||||
context: ${{ format('{0}/{1}/{2}', env.DOCKERFILES_DIRECTORY, matrix.build, matrix.os) }}
|
context: ${{ format('{0}/{1}/{2}', env.DOCKERFILES_DIRECTORY, matrix.build, matrix.os) }}
|
||||||
file: ${{ format('{0}/{1}/{2}/Dockerfile', env.DOCKERFILES_DIRECTORY, matrix.build, matrix.os) }}
|
file: ${{ format('{0}/{1}/{2}/Dockerfile', env.DOCKERFILES_DIRECTORY, matrix.build, matrix.os) }}
|
||||||
platforms: ${{ steps.platform.outputs.list }}
|
platforms: ${{ steps.platform.outputs.list }}
|
||||||
push: ${{ env.AUTO_PUSH_IMAGES }}
|
push: ${{ env.AUTO_PUSH_IMAGES == 'true' }}
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
build-args: BUILD_BASE_IMAGE=${{ steps.base_build.outputs.base_build_image }}
|
build-args: BUILD_BASE_IMAGE=${{ steps.base_build.outputs.base_build_image }}
|
||||||
labels: |
|
labels: |
|
||||||
org.opencontainers.image.revision=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
|
org.opencontainers.image.revision=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
|
||||||
org.opencontainers.image.created=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
|
org.opencontainers.image.created=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
|
||||||
cache-from: ${{ steps.cache_data.outputs.cache_from }}
|
|
||||||
|
|
||||||
- name: Sign the images with GitHub OIDC Token
|
- name: Sign the images with GitHub OIDC Token
|
||||||
|
if: ${{ env.AUTO_PUSH_IMAGES == 'true' }}
|
||||||
env:
|
env:
|
||||||
DIGEST: ${{ steps.docker_build.outputs.digest }}
|
DIGEST: ${{ steps.docker_build.outputs.digest }}
|
||||||
TAGS: ${{ steps.meta.outputs.tags }}
|
TAGS: ${{ steps.meta.outputs.tags }}
|
||||||
@ -993,8 +1007,8 @@ jobs:
|
|||||||
- name: Image metadata
|
- name: Image metadata
|
||||||
if: ${{ env.AUTO_PUSH_IMAGES == 'true' }}
|
if: ${{ env.AUTO_PUSH_IMAGES == 'true' }}
|
||||||
env:
|
env:
|
||||||
DIGEST: ${{ steps.docker_build.outputs.digest }}
|
METADATA: ${{ steps.docker_build.outputs.metadata }}
|
||||||
run: |
|
run: |
|
||||||
echo "::group::Image digest"
|
echo "::group::Image metadata"
|
||||||
echo "$DIGEST"
|
echo "${METADATA}"
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user