mirror of
https://github.com/zabbix/zabbix-docker.git
synced 2025-06-08 02:48:08 +02:00
Added workflow to update Red Hat Container Catalog
This commit is contained in:
parent
933171cb01
commit
426ed0b1a4
31
.github/scripts/rhel_description.py
vendored
Normal file
31
.github/scripts/rhel_description.py
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import sys
|
||||||
|
import requests
|
||||||
|
import json
|
||||||
|
import markdown
|
||||||
|
import os
|
||||||
|
|
||||||
|
repository_description = ''
|
||||||
|
|
||||||
|
if ("DESCRIPTION_FILE" not in os.environ):
|
||||||
|
print("Description file environment variable is not specified")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
if (os.path.isfile(os.environ["DESCRIPTION_FILE"] + '.md')):
|
||||||
|
repository_description=markdown.markdownFromFile(input=os.environ["DESCRIPTION_FILE"] + '.md')
|
||||||
|
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 (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(result)
|
||||||
|
print(json.loads(r.content)['last_update_date'])
|
29
.github/workflows/rhel_registry_description.yml
vendored
29
.github/workflows/rhel_registry_description.yml
vendored
@ -69,6 +69,7 @@ jobs:
|
|||||||
echo "::group::Branch metadata"
|
echo "::group::Branch metadata"
|
||||||
echo "secret_prefix=RHEL_${github_ref//.}"
|
echo "secret_prefix=RHEL_${github_ref//.}"
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
|
github_ref="64"
|
||||||
|
|
||||||
echo "secret_prefix=RHEL_${github_ref//.}" >> $GITHUB_OUTPUT
|
echo "secret_prefix=RHEL_${github_ref//.}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
@ -108,26 +109,20 @@ jobs:
|
|||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
echo "matrix_build=${MATRIX_BUILD}" >> $GITHUB_OUTPUT
|
echo "matrix_build=${MATRIX_BUILD}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: '3.x'
|
||||||
|
|
||||||
|
- name: install python packages
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install markdown
|
||||||
|
|
||||||
- name: Update Red Hat project description (zabbix-${{ matrix.component }})
|
- name: Update Red Hat project description (zabbix-${{ matrix.component }})
|
||||||
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.build) }}
|
||||||
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…
x
Reference in New Issue
Block a user