From 33e3dfaf44f3dbcd60e8c3757b5e2d7c311736b0 Mon Sep 17 00:00:00 2001 From: Alexey Pustovalov Date: Tue, 20 Feb 2024 00:58:59 +0900 Subject: [PATCH] Added workflow to update Red Hat Container Catalog --- .github/scripts/rhel_description.py | 19 ++++++++++++------- .../workflows/rhel_registry_description.yml | 3 +-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/scripts/rhel_description.py b/.github/scripts/rhel_description.py index 26c40b8a2..e16220020 100644 --- a/.github/scripts/rhel_description.py +++ b/.github/scripts/rhel_description.py @@ -6,16 +6,16 @@ import os repository_description = None -if ("DESCRIPTION_FILE" not in os.environ): +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): +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): +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): +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) @@ -38,6 +38,11 @@ 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(result.content)['last_update_date']) +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::") diff --git a/.github/workflows/rhel_registry_description.yml b/.github/workflows/rhel_registry_description.yml index 8305bdbf0..5ece50a38 100644 --- a/.github/workflows/rhel_registry_description.yml +++ b/.github/workflows/rhel_registry_description.yml @@ -65,13 +65,12 @@ jobs: sha_short=$(git rev-parse --short HEAD) github_ref=${github_ref##*/} - github_ref="6.4" echo "::group::Branch metadata" echo "secret_prefix=RHEL_${github_ref//.}" echo "::endgroup::" - echo "zabbix_release=64" >> $GITHUB_OUTPUT + echo "zabbix_release=${github_ref//.}" >> $GITHUB_OUTPUT echo "secret_prefix=RHEL_${github_ref//.}" >> $GITHUB_OUTPUT - name: Check ${{ env.MATRIX_FILE }} file