From 8deb0452f995052c2e237e1ea149b8fd183a6363 Mon Sep 17 00:00:00 2001
From: Lorenzo Pagliai <lorenzo.pagliai@seco.com>
Date: Fri, 24 Mar 2023 13:31:38 +0100
Subject: [PATCH] [REPORT] Chaange path to changelog and build reports

* Add condition to use public container to store report when a tag
occurs
---
 manifest-pipeline-yocto.yml | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/manifest-pipeline-yocto.yml b/manifest-pipeline-yocto.yml
index 30acdfa..ef82378 100644
--- a/manifest-pipeline-yocto.yml
+++ b/manifest-pipeline-yocto.yml
@@ -623,8 +623,11 @@ notify:
        echo -e "The changelog can be accessed by clicking on the **Changelog** button." >> Job_message.txt
        echo -e "*We kindly ask developers to check job results so that in case of failures a fix to eventual bugs can be promptly made.*" >> Job_message.txt
 
+       AZURE_PATH="edgehog/reports"
        if [ -n "$CI_COMMIT_TAG" ]; then
          tag=${CI_COMMIT_TAG}
+         AZURE_STORAGE_SAS_TOKEN="${AZURE_STORAGE_PUBLIC_SAS_TOKEN}"
+         AZURE_CONTAINER_NAME="${AZURE_PUBLIC_CONTAINER_NAME}"
        else
          tag=$(date +%Y%m%d)
        fi
@@ -641,33 +644,33 @@ notify:
                               --sas-token $AZURE_STORAGE_SAS_TOKEN \
                               --container-name $AZURE_CONTAINER_NAME \
                               --file Job_report_edgehog_${tag}.txt \
-                              --name Build_reports/Job_report_edgehog_${tag}.txt \
+                              --name ${AZURE_PATH}/Job_report_edgehog_${tag}.txt \
                               --overwrite
        
        az storage blob upload --account-name $AZURE_STORAGE_ACCOUNT \
                               --sas-token $AZURE_STORAGE_SAS_TOKEN \
                               --container-name $AZURE_CONTAINER_NAME \
                               --file Link_report_edgehog_${tag}.txt \
-                              --name Build_reports/Link_report_edgehog_${tag}.txt \
+                              --name ${AZURE_PATH}/Link_report_edgehog_${tag}.txt \
                               --overwrite
 
        az storage blob upload --account-name $AZURE_STORAGE_ACCOUNT \
                               --sas-token $AZURE_STORAGE_SAS_TOKEN \
                               --container-name $AZURE_CONTAINER_NAME \
                               --file Changelog_edgehog_${tag}.md \
-                              --name Build_reports/Changelog_edgehog_${tag}.md \
+                              --name ${AZURE_PATH}/Changelog_edgehog_${tag}.md \
                               --overwrite
 
        cp .gitlab-ci/notification.json .
-       job_report="$(az storage blob url --container-name $AZURE_CONTAINER_NAME --name Build_reports/Job_report_edgehog_${tag}.txt)"
+       job_report="$(az storage blob url --container-name $AZURE_CONTAINER_NAME --name ${AZURE_PATH}/Job_report_edgehog_${tag}.txt)"
        job_report="$(echo $job_report | sed -E 's/\s.*$//')"
        jq --arg job_var $job_report '.potentialAction[0].targets[0].uri = $job_var' notification.json > notification_1.json
 
-       link_report="$(az storage blob url --container-name $AZURE_CONTAINER_NAME --name Build_reports/Link_report_edgehog_${tag}.txt)"
+       link_report="$(az storage blob url --container-name $AZURE_CONTAINER_NAME --name ${AZURE_PATH}/Link_report_edgehog_${tag}.txt)"
        link_report="$(echo $link_report | sed -E 's/\s.*$//')"
        jq --arg link_var $link_report '.potentialAction[1].targets[0].uri = $link_var' notification_1.json > notification_2.json
 
-       changelog_report="$(az storage blob url --container-name $AZURE_CONTAINER_NAME --name Build_reports/Changelog_edgehog_${tag}.md)"
+       changelog_report="$(az storage blob url --container-name $AZURE_CONTAINER_NAME --name ${AZURE_PATH}/Changelog_edgehog_${tag}.md)"
        changelog_report="$(echo $changelog_report | sed -E 's/\s.*$//')"
        jq --arg changelog_var $changelog_report '.potentialAction[2].targets[0].uri = $changelog_var' notification_2.json > notification_3.json
        sed -i -E 's/\\"//g' notification_3.json
-- 
GitLab