mirror of
https://github.com/zabbix/zabbix-docker.git
synced 2025-02-02 10:59:18 +01:00
commit
b8f6c15e13
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("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("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("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("No description")
|
||||||
|
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: " + result)
|
||||||
|
print("Last update date: " + json.loads(result.content)['last_update_date'])
|
||||||
|
print("::endgroup::")
|
36
.github/workflows/rhel_registry_description.yml
vendored
36
.github/workflows/rhel_registry_description.yml
vendored
@ -3,9 +3,10 @@ name: Red Hat Catalog Description
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- 'trunk'
|
- '[0-9]+.[0-9]+'
|
||||||
paths:
|
paths:
|
||||||
- 'Dockerfiles/*/*/README.html'
|
- 'Dockerfiles/*/*/README.html'
|
||||||
|
- 'Dockerfiles/*/*/README.md'
|
||||||
- '.github/workflows/rhel_registry_description.yml'
|
- '.github/workflows/rhel_registry_description.yml'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
@ -70,6 +71,7 @@ jobs:
|
|||||||
echo "secret_prefix=RHEL_${github_ref//.}"
|
echo "secret_prefix=RHEL_${github_ref//.}"
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
|
|
||||||
|
echo "zabbix_release=${github_ref//.}" >> $GITHUB_OUTPUT
|
||||||
echo "secret_prefix=RHEL_${github_ref//.}" >> $GITHUB_OUTPUT
|
echo "secret_prefix=RHEL_${github_ref//.}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Check ${{ env.MATRIX_FILE }} file
|
- name: Check ${{ env.MATRIX_FILE }} file
|
||||||
@ -98,7 +100,7 @@ jobs:
|
|||||||
- name: Variables formating
|
- name: Variables formating
|
||||||
id: var_format
|
id: var_format
|
||||||
env:
|
env:
|
||||||
MATRIX_BUILD: ${{ matrix.build }}
|
MATRIX_BUILD: ${{ matrix.component }}
|
||||||
run: |
|
run: |
|
||||||
MATRIX_BUILD=${MATRIX_BUILD^^}
|
MATRIX_BUILD=${MATRIX_BUILD^^}
|
||||||
MATRIX_BUILD=${MATRIX_BUILD//-/_}
|
MATRIX_BUILD=${MATRIX_BUILD//-/_}
|
||||||
@ -108,26 +110,20 @@ jobs:
|
|||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
echo "matrix_build=${MATRIX_BUILD}" >> $GITHUB_OUTPUT
|
echo "matrix_build=${MATRIX_BUILD}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Update Red Hat project description (zabbix-${{ matrix.component }})
|
- uses: actions/setup-python@v4
|
||||||
|
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 (${{ matrix.component }}-${{ steps.branch_info.outputs.zabbix_release }})
|
||||||
env:
|
env:
|
||||||
DESCRIPTION_FILE: ${{ format('{0}/{1}/rhel/README.html', env.DOCKERFILES_DIRECTORY, matrix.build) }}
|
DESCRIPTION_FILE: ${{ format('{0}/{1}/rhel/README', env.DOCKERFILES_DIRECTORY, matrix.component) }}
|
||||||
PROJECT_ID: ${{ secrets[format('{0}_{1}_PROJECT', steps.branch_info.outputs.secret_prefix, steps.var_format.outputs.matrix_build)] }}
|
PROJECT_ID: ${{ secrets[format('{0}_{1}_PROJECT', steps.branch_info.outputs.secret_prefix, steps.var_format.outputs.matrix_build)] }}
|
||||||
PYXIS_API_TOKEN: ${{ secrets.REDHAT_API_TOKEN }}
|
PYXIS_API_TOKEN: ${{ secrets.REDHAT_API_TOKEN }}
|
||||||
API_URL: ${{ env.API_URL }}
|
API_URL: ${{ env.API_URL }}
|
||||||
run: |
|
run: python ./.github/scripts/rhel_description.py
|
||||||
import requests
|
|
||||||
import json
|
|
||||||
import os
|
|
||||||
|
|
||||||
file = open(os.environ["DESCRIPTION_FILE"],mode='r')
|
|
||||||
repository_description = file.read()
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
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(result)
|
|
||||||
print(json.loads(r.content)['last_update_date'])
|
|
||||||
|
Loading…
Reference in New Issue
Block a user