mirror of
https://github.com/zabbix/zabbix-docker.git
synced 2024-12-25 15:59:01 +01:00
Merge pull request #1234 from zabbix/workflow_60
Updated building images workflow
This commit is contained in:
commit
d6726d21dc
48
.github/scripts/rhel_description.py
vendored
Normal file
48
.github/scripts/rhel_description.py
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
import sys
|
||||
import requests
|
||||
import json
|
||||
import markdown
|
||||
import os
|
||||
|
||||
repository_description = None
|
||||
|
||||
if ("DESCRIPTION_FILE" not in os.environ or len(os.environ["DESCRIPTION_FILE"]) == 0):
|
||||
print("::error::Description file environment variable is not specified")
|
||||
sys.exit(1)
|
||||
if ("PYXIS_API_TOKEN" not in os.environ or len(os.environ["PYXIS_API_TOKEN"]) == 0):
|
||||
print("::error::API token environment variable is not specified")
|
||||
sys.exit(1)
|
||||
if ("API_URL" not in os.environ or len(os.environ["API_URL"]) == 0):
|
||||
print("::error::API URL environment variable is not specified")
|
||||
sys.exit(1)
|
||||
if ("PROJECT_ID" not in os.environ or len(os.environ["PROJECT_ID"]) == 0):
|
||||
print("RedHat project ID environment variable is not specified")
|
||||
sys.exit(1)
|
||||
|
||||
if (os.path.isfile(os.environ["DESCRIPTION_FILE"] + '.md')):
|
||||
file = open(os.environ["DESCRIPTION_FILE"] + '.md', mode='r')
|
||||
markdown_data = file.read()
|
||||
file.close()
|
||||
repository_description=markdown.markdown(markdown_data)
|
||||
elif (os.path.isfile(os.environ["DESCRIPTION_FILE"] + '.html')):
|
||||
file = open(os.environ["DESCRIPTION_FILE"] + '.html', mode='r')
|
||||
repository_description = file.read()
|
||||
file.close()
|
||||
|
||||
if (repository_description is None or len(repository_description) == 0):
|
||||
print("::error::No description file found")
|
||||
sys.exit(1)
|
||||
|
||||
data = dict()
|
||||
data['container'] = dict()
|
||||
data['container']['repository_description'] = repository_description[:32768]
|
||||
|
||||
headers = {'accept' : 'application/json', 'X-API-KEY' : os.environ["PYXIS_API_TOKEN"], 'Content-Type' : 'application/json'}
|
||||
result = requests.patch(os.environ["API_URL"] + os.environ["PROJECT_ID"],
|
||||
headers = headers,
|
||||
data = json.dumps(data))
|
||||
|
||||
print("::group::Result")
|
||||
print("Response code: " + str(result.status_code))
|
||||
print("Last update date: " + json.loads(result.content)['last_update_date'])
|
||||
print("::endgroup::")
|
3
.github/workflows/dependency-review.yml
vendored
3
.github/workflows/dependency-review.yml
vendored
@ -11,6 +11,7 @@ on: [pull_request]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
dependency-review:
|
||||
@ -28,4 +29,4 @@ jobs:
|
||||
- name: 'Checkout Repository'
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
- name: 'Dependency Review'
|
||||
uses: actions/dependency-review-action@80f10bf419f34980065523f5efca7ebed17576aa # v4.1.0
|
||||
uses: actions/dependency-review-action@be8bc500ee15e96754d2a6f2d34be14e945a46f3 # v4.1.2
|
||||
|
603
.github/workflows/images_build.yml
vendored
603
.github/workflows/images_build.yml
vendored
File diff suppressed because it is too large
Load Diff
45
.github/workflows/images_build_rhel.yml
vendored
45
.github/workflows/images_build_rhel.yml
vendored
@ -29,7 +29,8 @@ permissions:
|
||||
contents: read
|
||||
|
||||
env:
|
||||
AUTO_PUSH_IMAGES: ${{ contains(fromJSON('["workflow_dispatch", "push"]'), github.event_name) && 'false' || vars.AUTO_PUSH_IMAGES }}
|
||||
TRUNK_ONLY_EVENT: ${{ contains(fromJSON('["schedule"]'), github.event_name) }}
|
||||
AUTO_PUSH_IMAGES: ${{ ! contains(fromJSON('["workflow_dispatch", "push"]'), github.event_name) && vars.AUTO_PUSH_IMAGES }}
|
||||
|
||||
LATEST_BRANCH: ${{ github.event.repository.default_branch }}
|
||||
TRUNK_GIT_BRANCH: "refs/heads/trunk"
|
||||
@ -164,7 +165,7 @@ jobs:
|
||||
echo "secret_prefix=RHEL_${github_ref//.}" >> $GITHUB_OUTPUT
|
||||
echo "sha_short=$sha_short" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Cleanup cache
|
||||
- name: Cleanup existing cache
|
||||
shell: bash
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@ -205,11 +206,13 @@ jobs:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Install cosign
|
||||
if: ${{ env.AUTO_PUSH_IMAGES == 'true' }}
|
||||
uses: sigstore/cosign-installer@e1523de7571e31dbe865fd2e80c5c7c23ae71eb4
|
||||
with:
|
||||
cosign-release: 'v2.2.3'
|
||||
|
||||
- name: Check cosign version
|
||||
if: ${{ env.AUTO_PUSH_IMAGES == 'true' }}
|
||||
run: cosign version
|
||||
|
||||
- name: Fix string case
|
||||
@ -231,7 +234,7 @@ jobs:
|
||||
id: build_image
|
||||
uses: redhat-actions/buildah-build@b4dc19b4ba891854660ab1f88a097d45aa158f76 # v2.12
|
||||
with:
|
||||
context: ${{ env.DOCKERFILES_DIRECTORY }}/${{ matrix.build }}/rhel
|
||||
context: ${{ format('{0}/{1}/rhel', env.DOCKERFILES_DIRECTORY, matrix.build) }}
|
||||
layers: false
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
containerfiles: |
|
||||
@ -240,7 +243,7 @@ jobs:
|
||||
--pull
|
||||
--iidfile=${{ github.workspace }}/iidfile
|
||||
|
||||
- name: Prepare image metadata
|
||||
- name: Image metadata
|
||||
id: image_metadata
|
||||
env:
|
||||
IMAGE_TAG: ${{ steps.build_image.outputs.image-with-tag }}
|
||||
@ -279,7 +282,6 @@ jobs:
|
||||
IMAGE_TAG: ${{ steps.image_metadata.outputs.image_tag }}
|
||||
IMAGE_TAG_ID: ${{ steps.image_metadata.outputs.image_tag_id }}
|
||||
IMAGE_DIR: ${{ env.IMAGE_DIR }}
|
||||
GITHUB_WORKSPACE: ${{ github.workspace }}
|
||||
run: |
|
||||
echo "::group::Result"
|
||||
echo "Image ${IMAGE_TAG} location: \"${IMAGE_DIR}/${IMAGE_TAG_ID}\""
|
||||
@ -310,13 +312,14 @@ jobs:
|
||||
if: ${{ (cancelled() || failure()) && ( steps.push_image.outcome == 'failure' || steps.push_image.outcome == 'cancelled') }}
|
||||
env:
|
||||
IMAGE_TAG_ID: ${{ steps.image_metadata.outputs.image_tag_id }}
|
||||
IMAGE_DIR: ${{ env.IMAGE_DIR }}
|
||||
run: |
|
||||
echo "::group::Removing orphaned image"
|
||||
rm -rf "${IMAGE_DIR}/${IMAGE_TAG_ID}"
|
||||
echo "::endgroup::"
|
||||
|
||||
build_base_database:
|
||||
timeout-minutes: 180
|
||||
timeout-minutes: 90
|
||||
needs: [ "build_base", "init_build"]
|
||||
name: Build ${{ matrix.build }} base (${{ matrix.arch }})
|
||||
strategy:
|
||||
@ -348,7 +351,7 @@ jobs:
|
||||
${{ env.BASE_BUILD_NAME }}_${{ matrix.arch }}_tag
|
||||
key: ${{ env.BASE_BUILD_NAME }}-${{ matrix.arch }}-${{ github.run_id }}
|
||||
|
||||
- name: Pull ${{ env.BASE_BUILD_NAME }}:${{ matrix.arch }} image
|
||||
- name: Pull ${{ env.BASE_BUILD_NAME }}:${{ matrix.arch }} image from local storage
|
||||
id: base_build
|
||||
env:
|
||||
MATRIX_ARCH: ${{ matrix.arch }}
|
||||
@ -389,7 +392,7 @@ jobs:
|
||||
id: build_image
|
||||
uses: redhat-actions/buildah-build@b4dc19b4ba891854660ab1f88a097d45aa158f76 # v2.12
|
||||
with:
|
||||
context: ${{ env.DOCKERFILES_DIRECTORY }}/${{ matrix.build }}/rhel
|
||||
context: ${{ format('{0}/{1}/rhel', env.DOCKERFILES_DIRECTORY, matrix.build) }}
|
||||
layers: false
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
containerfiles: |
|
||||
@ -423,7 +426,7 @@ jobs:
|
||||
echo "image_tag_id=${TAG_ID}" >> $GITHUB_OUTPUT
|
||||
echo "image_tag=${IMAGE_TAG}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Cache image digest
|
||||
- name: Cache image metadata
|
||||
uses: actions/cache/save@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
|
||||
with:
|
||||
path: |
|
||||
@ -437,7 +440,6 @@ jobs:
|
||||
IMAGE_TAG: ${{ steps.image_metadata.outputs.image_tag }}
|
||||
IMAGE_TAG_ID: ${{ steps.image_metadata.outputs.image_tag_id }}
|
||||
IMAGE_DIR: ${{ env.IMAGE_DIR }}
|
||||
GITHUB_WORKSPACE: ${{ github.workspace }}
|
||||
run: |
|
||||
echo "::group::Result"
|
||||
echo "podman push \"${IMAGE_TAG}\" dir:\"${IMAGE_DIR}/${IMAGE_TAG_ID}\""
|
||||
@ -468,13 +470,14 @@ jobs:
|
||||
if: ${{ (cancelled() || failure()) && ( steps.push_image.outcome == 'failure' || steps.push_image.outcome == 'cancelled') }}
|
||||
env:
|
||||
IMAGE_TAG_ID: ${{ steps.image_metadata.outputs.image_tag_id }}
|
||||
IMAGE_DIR: ${{ env.IMAGE_DIR }}
|
||||
run: |
|
||||
echo "::group::Removing orphaned image"
|
||||
rm -rf "${IMAGE_DIR}/${IMAGE_TAG_ID}"
|
||||
echo "::endgroup::"
|
||||
|
||||
build_images:
|
||||
timeout-minutes: 90
|
||||
timeout-minutes: 30
|
||||
needs: [ "build_base_database", "init_build"]
|
||||
name: Build ${{ matrix.build }} image (${{ matrix.arch }})
|
||||
strategy:
|
||||
@ -580,7 +583,7 @@ jobs:
|
||||
id: build_image
|
||||
uses: redhat-actions/buildah-build@b4dc19b4ba891854660ab1f88a097d45aa158f76 # v2.12
|
||||
with:
|
||||
context: ${{ env.DOCKERFILES_DIRECTORY }}/${{ matrix.build }}/rhel
|
||||
context: ${{ format('{0}/{1}/rhel', env.DOCKERFILES_DIRECTORY, matrix.build) }}
|
||||
layers: false
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: |
|
||||
@ -588,6 +591,9 @@ jobs:
|
||||
org.opencontainers.image.created=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
|
||||
containerfiles: |
|
||||
${{ env.DOCKERFILES_DIRECTORY }}/${{ matrix.build }}/rhel/Dockerfile
|
||||
extra-args: |
|
||||
--pull
|
||||
--iidfile=${{ github.workspace }}/iidfile
|
||||
build-args: BUILD_BASE_IMAGE=${{ steps.base_build.outputs.base_build_image }}
|
||||
|
||||
- name: Log in to ${{ env.REGISTRY }}
|
||||
@ -657,11 +663,24 @@ jobs:
|
||||
podman rmi -i -f "$PREFLIGHT_IMAGE"
|
||||
echo "::endgroup::"
|
||||
|
||||
- name: Image digest
|
||||
env:
|
||||
GITHUB_WORKSPACE: ${{ github.workspace }}
|
||||
run: |
|
||||
TAG_ID=$(cat $GITHUB_WORKSPACE/iidfile)
|
||||
echo "::group::Image digest"
|
||||
echo "$TAG_ID"
|
||||
echo "::endgroup::"
|
||||
|
||||
- name: Post build image
|
||||
if: ${{ success() || failure() }}
|
||||
env:
|
||||
GITHUB_WORKSPACE: ${{ github.workspace }}
|
||||
run: |
|
||||
echo "::group::Result"
|
||||
|
||||
rm -rf "$GITHUB_WORKSPACE/iidfile"
|
||||
|
||||
echo "Removing working containers"
|
||||
buildah rm -a 2>/dev/null || true
|
||||
echo "Removing container data in storage not controlled by podman"
|
||||
@ -674,7 +693,7 @@ jobs:
|
||||
echo "::endgroup::"
|
||||
|
||||
clear_artifacts:
|
||||
timeout-minutes: 90
|
||||
timeout-minutes: 10
|
||||
needs: [ "build_images", "init_build"]
|
||||
name: Clear ${{ matrix.build }} image cache (${{ matrix.arch }})
|
||||
strategy:
|
||||
|
156
.github/workflows/rhel_registry_description.yml
vendored
Normal file
156
.github/workflows/rhel_registry_description.yml
vendored
Normal file
@ -0,0 +1,156 @@
|
||||
name: Red Hat Catalog Description
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '[0-9]+.[0-9]+'
|
||||
paths:
|
||||
- 'Dockerfiles/*/*/README.html'
|
||||
- 'Dockerfiles/*/*/README.md'
|
||||
- '.github/workflows/rhel_registry_description.yml'
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
DOCKERFILES_DIRECTORY: "./Dockerfiles"
|
||||
API_URL: "https://catalog.redhat.com/api/containers/v1/projects/certification/id/"
|
||||
MATRIX_FILE: "build.json"
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
init:
|
||||
name: Initialize workflow
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
outputs:
|
||||
components: ${{ steps.components.outputs.list }}
|
||||
zabbix_release: ${{ steps.branch_info.outputs.zabbix_release }}
|
||||
steps:
|
||||
- name: Block egress traffic
|
||||
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
|
||||
with:
|
||||
disable-sudo: true
|
||||
egress-policy: block
|
||||
allowed-endpoints: >
|
||||
github.com:443
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
with:
|
||||
fetch-depth: 1
|
||||
sparse-checkout: ${{ env.MATRIX_FILE }}
|
||||
|
||||
- name: Check ${{ env.MATRIX_FILE }} file
|
||||
id: build_exists
|
||||
env:
|
||||
MATRIX_FILE: ${{ env.MATRIX_FILE }}
|
||||
run: |
|
||||
if [[ ! -f "$MATRIX_FILE" ]]; then
|
||||
echo "::error::File $MATRIX_FILE is missing"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Get branch info
|
||||
id: branch_info
|
||||
shell: bash
|
||||
env:
|
||||
github_ref: ${{ github.ref }}
|
||||
run: |
|
||||
result=false
|
||||
|
||||
github_ref=${github_ref##*/}
|
||||
|
||||
echo "::group::Branch metadata"
|
||||
echo "zabbix_release=${github_ref//.}"
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "zabbix_release=${github_ref//.}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Prepare Zabbix component list
|
||||
id: components
|
||||
env:
|
||||
MATRIX_FILE: ${{ env.MATRIX_FILE }}
|
||||
run: |
|
||||
component_list=$(jq -r '.components | map_values(select(.rhel == true)) | keys | @json' "$MATRIX_FILE")
|
||||
|
||||
echo "::group::Zabbix Component List"
|
||||
echo "$component_list"
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "list=$component_list" >> $GITHUB_OUTPUT
|
||||
|
||||
publish:
|
||||
name: Initialize build
|
||||
runs-on: ubuntu-latest
|
||||
needs: init
|
||||
permissions:
|
||||
contents: read
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
component: ${{ fromJson(needs.init.outputs.components) }}
|
||||
steps:
|
||||
- name: Block egress traffic
|
||||
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
|
||||
with:
|
||||
disable-sudo: true
|
||||
egress-policy: block
|
||||
allowed-endpoints: >
|
||||
catalog.redhat.com:443
|
||||
files.pythonhosted.org:443
|
||||
github.com:443
|
||||
pypi.org:443
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Variables formating
|
||||
id: var_format
|
||||
env:
|
||||
MATRIX_BUILD: ${{ matrix.component }}
|
||||
run: |
|
||||
MATRIX_BUILD=${MATRIX_BUILD^^}
|
||||
MATRIX_BUILD=${MATRIX_BUILD//-/_}
|
||||
|
||||
echo "::group::Result"
|
||||
echo "matrix_build=${MATRIX_BUILD}"
|
||||
echo "::endgroup::"
|
||||
echo "matrix_build=${MATRIX_BUILD}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Setup Python 3.x
|
||||
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
|
||||
with:
|
||||
python-version: '3.x'
|
||||
|
||||
- name: Install Python packages
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install markdown requests
|
||||
|
||||
- name: Update Red Hat project description
|
||||
env:
|
||||
DESCRIPTION_FILE: ${{ format('{0}/{1}/rhel/README', env.DOCKERFILES_DIRECTORY, matrix.component) }}
|
||||
PROJECT_ID: ${{ secrets[format('RHEL_{0}_{1}_PROJECT', needs.init.outputs.zabbix_release, steps.var_format.outputs.matrix_build)] }}
|
||||
PYXIS_API_TOKEN: ${{ secrets.REDHAT_API_TOKEN }}
|
||||
API_URL: ${{ env.API_URL }}
|
||||
run: |
|
||||
python ./.github/scripts/rhel_description.py
|
||||
|
||||
- name: Red Hat Gatalog URL
|
||||
env:
|
||||
COMPONENT: ${{ matrix.component }}
|
||||
MATRIX_FILE: ${{ env.MATRIX_FILE }}
|
||||
run: |
|
||||
PROJECT_ID=$(jq -r ".components.\"$COMPONENT\".rhel_project" "$MATRIX_FILE")
|
||||
|
||||
echo "::group::URL"
|
||||
echo "https://catalog.redhat.com/software/containers/${PROJECT_ID}"
|
||||
echo "::endgroup::"
|
2
.github/workflows/scorecard.yml
vendored
2
.github/workflows/scorecard.yml
vendored
@ -73,6 +73,6 @@ jobs:
|
||||
|
||||
# Upload the results to GitHub's code scanning dashboard.
|
||||
- name: "Upload to code-scanning"
|
||||
uses: github/codeql-action/upload-sarif@e675ced7a7522a761fc9c8eb26682c8b27c42b2b # v3.24.1
|
||||
uses: github/codeql-action/upload-sarif@379614612a29c9e28f31f39a59013eb8012a51f0 # v3.24.3
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
|
18
build.json
18
build.json
@ -32,18 +32,18 @@
|
||||
"windows-2022": "ltsc2022"
|
||||
},
|
||||
"components": {
|
||||
"agent": { "base": "build-mysql", "rhel": true },
|
||||
"agent2": { "base": "build-mysql", "rhel": true },
|
||||
"java-gateway": { "base": "build-mysql", "rhel": true },
|
||||
"proxy-mysql": { "base": "build-mysql", "rhel": true },
|
||||
"proxy-sqlite3": { "base": "build-sqlite3", "rhel": true },
|
||||
"server-mysql": { "base": "build-mysql", "rhel": true },
|
||||
"agent": { "base": "build-mysql", "rhel": true, "rhel_project": "622f43b04a14c05796114d0d" },
|
||||
"agent2": { "base": "build-mysql", "rhel": true, "rhel_project": "622f439c146e47a748c01a8c" },
|
||||
"java-gateway": { "base": "build-mysql", "rhel": true, "rhel_project": "622f43c1146e47a748c01a8d" },
|
||||
"proxy-mysql": { "base": "build-mysql", "rhel": true, "rhel_project": "622f43ac4a14c05796114d0c" },
|
||||
"proxy-sqlite3": { "base": "build-sqlite3", "rhel": true, "rhel_project": "622f43c2146e47a748c01a8e" },
|
||||
"server-mysql": { "base": "build-mysql", "rhel": true, "rhel_project": "622f43bb4a14c05796114d0e" },
|
||||
"server-pgsql": { "base": "build-pgsql", "rhel": false },
|
||||
"snmptraps": { "base": "", "rhel": true },
|
||||
"snmptraps": { "base": "", "rhel": true, "rhel_project": "622f43914a14c05796114d0b" },
|
||||
"web-apache-mysql": { "base": "build-mysql", "rhel": false },
|
||||
"web-apache-pgsql": { "base": "build-pgsql", "rhel": false },
|
||||
"web-nginx-mysql": { "base": "build-mysql", "rhel": true },
|
||||
"web-nginx-mysql": { "base": "build-mysql", "rhel": true, "rhel_project": "622f43b72e84c15317c26ed0" },
|
||||
"web-nginx-pgsql": { "base": "build-mysql", "rhel": false },
|
||||
"web-service": { "base": "build-mysql", "rhel": true }
|
||||
"web-service": { "base": "build-mysql", "rhel": true, "rhel_project": "622f43c9f19c93b02846c894" }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user