From e6f57ad2660150bdb8e997e6b7040a5db3413412 Mon Sep 17 00:00:00 2001 From: pasqualespica <36746022+pasqualespica@users.noreply.github.com> Date: Thu, 30 Nov 2023 17:27:02 +0100 Subject: [PATCH 01/15] fix --- .github/workflows/daily_report_receipt.yml | 24 +--------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/.github/workflows/daily_report_receipt.yml b/.github/workflows/daily_report_receipt.yml index 5073ceca..4cfe840c 100644 --- a/.github/workflows/daily_report_receipt.yml +++ b/.github/workflows/daily_report_receipt.yml @@ -71,10 +71,7 @@ jobs: cd ./report chmod +x ./run.sh ./run.sh local > report.md && grep ">" report.md > report.cp && mv report.cp report.md - echo "REPORT_PDF=$(cat report.md)" >> $GITHUB_ENV - echo "CVE_MEDIUM=$(echo $SCAN_RESULTS | grep -o MEDIUM | wc -l)" >> $GITHUB_ENV - debug_script: needs: [ report_script ] @@ -90,26 +87,7 @@ jobs: echo "Below ๐Ÿ‘‡ PDF's daily report ๐Ÿงพ" - echo $REPORT_PDF - - # notify: - # needs: [ create_runner, report_script ] - # runs-on: [ self-hosted, "${{ needs.create_runner.outputs.runner_name }}" ] - # name: Notify - # if: always() - # steps: - # - name: Report Status - # if: always() - # uses: ravsamhq/notify-slack-action@v2 - # with: - # status: ${{ needs.integration_test.result }} - # token: ${{ secrets.GITHUB_TOKEN }} - # notify_when: 'failure,skipped' - # notification_title: "<{run_url}|Scheduled Integration Test> has {status_message} in ${{( github.event.inputs == null && 'uat') || inputs.environment }} env" - # message_format: '{emoji} <{run_url}|{workflow}> {status_message} in <{repo_url}|{repo}>' - # footer: 'Linked to <{workflow_url}| workflow file>' - # env: - # SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + echo ${{ env.REPORT_PDF }} cleanup_runner: name: Cleanup Runner From b14735c1fbb5f517fce8c462557fb24a7f4fae0c Mon Sep 17 00:00:00 2001 From: pasqualespica <36746022+pasqualespica@users.noreply.github.com> Date: Thu, 30 Nov 2023 17:38:47 +0100 Subject: [PATCH 02/15] fix --- .github/workflows/daily_report_receipt.yml | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/daily_report_receipt.yml b/.github/workflows/daily_report_receipt.yml index 4cfe840c..587145ac 100644 --- a/.github/workflows/daily_report_receipt.yml +++ b/.github/workflows/daily_report_receipt.yml @@ -66,12 +66,23 @@ jobs: - name: Run reports shell: bash run: | - export RECEIPTS_COSMOS_CONN_STRING='${{ secrets.RECEIPTS_COSMOS_CONN_STRING }}' - cd ./report - chmod +x ./run.sh - ./run.sh local > report.md && grep ">" report.md > report.cp && mv report.cp report.md - echo "REPORT_PDF=$(cat report.md)" >> $GITHUB_ENV + export RECEIPTS_COSMOS_CONN_STRING='${{ secrets.RECEIPTS_COSMOS_CONN_STRING }}' + + cd ./report + chmod +x ./run.sh + ./run.sh local > report.md && grep ">" report.md > report.cp && mv report.cp report.md + { + echo '๐Ÿ“ˆ PDF's daily report ๐Ÿงพ receipt ๐Ÿ‘€<> $GITHUB_ENV + + { + echo 'JSON_RESPONSE<> "$GITHUB_ENV" debug_script: needs: [ report_script ] From 70da0ca7da7928c14d9c147861b03ad88f0888a5 Mon Sep 17 00:00:00 2001 From: pasqualespica <36746022+pasqualespica@users.noreply.github.com> Date: Thu, 30 Nov 2023 18:00:46 +0100 Subject: [PATCH 03/15] fix --- .github/workflows/daily_report_receipt.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/daily_report_receipt.yml b/.github/workflows/daily_report_receipt.yml index 587145ac..4f01665d 100644 --- a/.github/workflows/daily_report_receipt.yml +++ b/.github/workflows/daily_report_receipt.yml @@ -72,17 +72,17 @@ jobs: cd ./report chmod +x ./run.sh ./run.sh local > report.md && grep ">" report.md > report.cp && mv report.cp report.md - { - echo '๐Ÿ“ˆ PDF's daily report ๐Ÿงพ receipt ๐Ÿ‘€<> $GITHUB_ENV - - { - echo 'JSON_RESPONSE<> "$GITHUB_ENV" + + + - name: Set the value in bash + id: save-env-report + run: | + { + echo '๐Ÿ“ˆ PDF's daily report ๐Ÿงพ receipt ๐Ÿ‘€<> "$GITHUB_ENV" + debug_script: needs: [ report_script ] From 05865300b82f249764441b103c31813f650cc7e9 Mon Sep 17 00:00:00 2001 From: pasqualespica <36746022+pasqualespica@users.noreply.github.com> Date: Thu, 30 Nov 2023 18:06:49 +0100 Subject: [PATCH 04/15] fix --- .github/workflows/daily_report_receipt.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/daily_report_receipt.yml b/.github/workflows/daily_report_receipt.yml index 4f01665d..42035cab 100644 --- a/.github/workflows/daily_report_receipt.yml +++ b/.github/workflows/daily_report_receipt.yml @@ -78,8 +78,8 @@ jobs: id: save-env-report run: | { - echo '๐Ÿ“ˆ PDF's daily report ๐Ÿงพ receipt ๐Ÿ‘€<> "$GITHUB_ENV" From 88d3e049bc481490910b4341bdba00434f10b0fc Mon Sep 17 00:00:00 2001 From: pasqualespica <36746022+pasqualespica@users.noreply.github.com> Date: Thu, 30 Nov 2023 18:42:35 +0100 Subject: [PATCH 05/15] fix --- .github/workflows/daily_report_receipt.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/daily_report_receipt.yml b/.github/workflows/daily_report_receipt.yml index 42035cab..d97fa18a 100644 --- a/.github/workflows/daily_report_receipt.yml +++ b/.github/workflows/daily_report_receipt.yml @@ -77,6 +77,7 @@ jobs: - name: Set the value in bash id: save-env-report run: | + cd ./report { echo 'REPORT_PDF< Date: Thu, 30 Nov 2023 18:47:45 +0100 Subject: [PATCH 06/15] fix --- .github/workflows/daily_report_receipt.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.github/workflows/daily_report_receipt.yml b/.github/workflows/daily_report_receipt.yml index d97fa18a..77615aef 100644 --- a/.github/workflows/daily_report_receipt.yml +++ b/.github/workflows/daily_report_receipt.yml @@ -84,21 +84,10 @@ jobs: echo EOF } >> "$GITHUB_ENV" - - debug_script: - needs: [ report_script ] - name: Debug Report ${{(github.event.inputs == null && 'prod') || inputs.environment }} - runs-on: [ self-hosted, "${{ needs.create_runner.outputs.runner_name }}" ] - environment: ${{(github.event.inputs == null && 'prod') || inputs.environment }} - steps: - - name: Debug reports shell: bash run: | - export RECEIPTS_COSMOS_CONN_STRING='${{ secrets.RECEIPTS_COSMOS_CONN_STRING }}' - echo "Below ๐Ÿ‘‡ PDF's daily report ๐Ÿงพ" - echo ${{ env.REPORT_PDF }} cleanup_runner: From b9b3cdaff389ec8e6cb50af5724ca7068eae654b Mon Sep 17 00:00:00 2001 From: pasqualespica <36746022+pasqualespica@users.noreply.github.com> Date: Thu, 30 Nov 2023 18:54:10 +0100 Subject: [PATCH 07/15] fix --- .github/workflows/daily_report_receipt.yml | 1 - report/src/utils/report.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/daily_report_receipt.yml b/.github/workflows/daily_report_receipt.yml index 77615aef..134bd5fd 100644 --- a/.github/workflows/daily_report_receipt.yml +++ b/.github/workflows/daily_report_receipt.yml @@ -87,7 +87,6 @@ jobs: - name: Debug reports shell: bash run: | - echo "Below ๐Ÿ‘‡ PDF's daily report ๐Ÿงพ" echo ${{ env.REPORT_PDF }} cleanup_runner: diff --git a/report/src/utils/report.js b/report/src/utils/report.js index f031bf7d..7c03aea8 100644 --- a/report/src/utils/report.js +++ b/report/src/utils/report.js @@ -58,7 +58,7 @@ const dictionary = { "NOT_TO_NOTIFY" : "๐ŸŸข" } -console.log(`> Report receipt of ${yesterday_}`); +console.log(`> Report ๐Ÿ“ˆ receipt ๐Ÿงพ of ${yesterday_} ๐Ÿง`); res.then(function(result) { console.log(result.resources.forEach(e => { console.log(`> ${dictionary[e.status]} ${e.num.toString().padEnd(8, ' ')}\t ${e.status} `); From 7a3ae4157cc2292fac9aaad9579e973eba267467 Mon Sep 17 00:00:00 2001 From: pasqualespica <36746022+pasqualespica@users.noreply.github.com> Date: Thu, 30 Nov 2023 18:56:35 +0100 Subject: [PATCH 08/15] fix --- .github/workflows/daily_report_receipt.yml | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/.github/workflows/daily_report_receipt.yml b/.github/workflows/daily_report_receipt.yml index 134bd5fd..d3b08e5c 100644 --- a/.github/workflows/daily_report_receipt.yml +++ b/.github/workflows/daily_report_receipt.yml @@ -89,6 +89,34 @@ jobs: run: | echo ${{ env.REPORT_PDF }} + - name: Send notification to Slack + id: slack + if: always() + uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 #v1.24.0 + with: + payload: | + { + "blocks": [ + { + "type": "header", + "text": { + "type": "plain_text", + "text": "[ ${{ github.event.repository.name }} ]" + } + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "${{ env.REPORT_PDF }}" + } + } + ] + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK + cleanup_runner: name: Cleanup Runner needs: [ create_runner, report_script ] From a3e03ee69e89e16cd04adbbca415a530251c2c5b Mon Sep 17 00:00:00 2001 From: pasqualespica <36746022+pasqualespica@users.noreply.github.com> Date: Thu, 30 Nov 2023 18:57:32 +0100 Subject: [PATCH 09/15] fix --- .github/workflows/daily_report_receipt.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/daily_report_receipt.yml b/.github/workflows/daily_report_receipt.yml index d3b08e5c..46646a46 100644 --- a/.github/workflows/daily_report_receipt.yml +++ b/.github/workflows/daily_report_receipt.yml @@ -84,10 +84,10 @@ jobs: echo EOF } >> "$GITHUB_ENV" - - name: Debug reports - shell: bash - run: | - echo ${{ env.REPORT_PDF }} + # - name: Debug reports + # shell: bash + # run: | + # echo ${{ env.REPORT_PDF }} - name: Send notification to Slack id: slack From f91c3b394df469e91c581122d6f15340b4fb7c6e Mon Sep 17 00:00:00 2001 From: pasqualespica <36746022+pasqualespica@users.noreply.github.com> Date: Thu, 30 Nov 2023 19:04:12 +0100 Subject: [PATCH 10/15] fix --- .github/workflows/daily_report_receipt.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/daily_report_receipt.yml b/.github/workflows/daily_report_receipt.yml index 46646a46..faee2c68 100644 --- a/.github/workflows/daily_report_receipt.yml +++ b/.github/workflows/daily_report_receipt.yml @@ -108,7 +108,10 @@ jobs: "type": "section", "text": { "type": "mrkdwn", - "text": "${{ env.REPORT_PDF }}" + "text": " `Report ๐Ÿ“ˆ receipt ๐Ÿงพ of`: `2023-11-29` + `๐ŸŸข NOT_TO_NOTIFY`: `1498099` + `๐Ÿ”ด IO_ERROR_TO_NOTIFY`: `574` + }" } } ] From a9ec309260e5231e0c661fd1113428163bc51dc5 Mon Sep 17 00:00:00 2001 From: pasqualespica <36746022+pasqualespica@users.noreply.github.com> Date: Thu, 30 Nov 2023 22:59:05 +0100 Subject: [PATCH 11/15] fix --- .github/workflows/daily_report_receipt.yml | 43 ++++++---------------- report/src/utils/report.js | 27 +++++++++++--- 2 files changed, 33 insertions(+), 37 deletions(-) diff --git a/.github/workflows/daily_report_receipt.yml b/.github/workflows/daily_report_receipt.yml index faee2c68..eb34b474 100644 --- a/.github/workflows/daily_report_receipt.yml +++ b/.github/workflows/daily_report_receipt.yml @@ -71,18 +71,18 @@ jobs: cd ./report chmod +x ./run.sh - ./run.sh local > report.md && grep ">" report.md > report.cp && mv report.cp report.md + ./run.sh local - - name: Set the value in bash - id: save-env-report - run: | - cd ./report - { - echo 'REPORT_PDF<> "$GITHUB_ENV" + # - name: Set the value in bash + # id: save-env-report + # run: | + # cd ./report + # { + # echo 'REPORT_PDF<> "$GITHUB_ENV" # - name: Debug reports # shell: bash @@ -94,28 +94,7 @@ jobs: if: always() uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 #v1.24.0 with: - payload: | - { - "blocks": [ - { - "type": "header", - "text": { - "type": "plain_text", - "text": "[ ${{ github.event.repository.name }} ]" - } - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": " `Report ๐Ÿ“ˆ receipt ๐Ÿงพ of`: `2023-11-29` - `๐ŸŸข NOT_TO_NOTIFY`: `1498099` - `๐Ÿ”ด IO_ERROR_TO_NOTIFY`: `574` - }" - } - } - ] - } + payload-file-path: "./report/report.json" env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK diff --git a/report/src/utils/report.js b/report/src/utils/report.js index 7c03aea8..4cd90ad9 100644 --- a/report/src/utils/report.js +++ b/report/src/utils/report.js @@ -1,3 +1,5 @@ +const fs = require('fs'); + const { getReceiptsStatusCount } = require("./utils"); // const from = "2023-11-23T00:00:00"; @@ -58,9 +60,24 @@ const dictionary = { "NOT_TO_NOTIFY" : "๐ŸŸข" } -console.log(`> Report ๐Ÿ“ˆ receipt ๐Ÿงพ of ${yesterday_} ๐Ÿง`); -res.then(function(result) { - console.log(result.resources.forEach(e => { - console.log(`> ${dictionary[e.status]} ${e.num.toString().padEnd(8, ' ')}\t ${e.status} `); - })) + +let report_ = '{"title":"","detail":[]}' + +report=JSON.parse(report_); + +report.title = "Report ๐Ÿ“ˆ receipt ๐Ÿงพ of ${yesterday_} ๐Ÿง" +let p = res.then(function(result) { + // console.log(result.resources.forEach(e => { + // console.log(`> ${dictionary[e.status]} ${e.num.toString().padEnd(8, ' ')}\t ${e.status} `); + // })) + let index = 0; + result.resources.forEach(e => { + report["detail"].push( {"status": `${dictionary[e.status]} ${e.status}`, "num":`${e.num}` }); + }) + + console.log(JSON.stringify(report)); + fs.writeFileSync('report.json', JSON.stringify(report)); + + }) + From 2f59e41c997154474dbb8ecbf62bdc64cc22ba9d Mon Sep 17 00:00:00 2001 From: pasqualespica <36746022+pasqualespica@users.noreply.github.com> Date: Thu, 30 Nov 2023 23:09:54 +0100 Subject: [PATCH 12/15] fix --- .github/workflows/daily_report_receipt.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/daily_report_receipt.yml b/.github/workflows/daily_report_receipt.yml index eb34b474..59e8f173 100644 --- a/.github/workflows/daily_report_receipt.yml +++ b/.github/workflows/daily_report_receipt.yml @@ -94,7 +94,7 @@ jobs: if: always() uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 #v1.24.0 with: - payload-file-path: "./report/report.json" + payload-file-path: "./report/src/report.json" env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK From 309bbdde7ba3ae888d7d8acfccdfdd1c8a04bcae Mon Sep 17 00:00:00 2001 From: pasqualespica <36746022+pasqualespica@users.noreply.github.com> Date: Thu, 30 Nov 2023 23:19:46 +0100 Subject: [PATCH 13/15] fix --- report/src/utils/report.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/report/src/utils/report.js b/report/src/utils/report.js index 4cd90ad9..f8473c5f 100644 --- a/report/src/utils/report.js +++ b/report/src/utils/report.js @@ -65,7 +65,7 @@ let report_ = '{"title":"","detail":[]}' report=JSON.parse(report_); -report.title = "Report ๐Ÿ“ˆ receipt ๐Ÿงพ of ${yesterday_} ๐Ÿง" +report.title = `Report ๐Ÿ“ˆ receipt ๐Ÿงพ of ${yesterday_} ๐Ÿง` let p = res.then(function(result) { // console.log(result.resources.forEach(e => { // console.log(`> ${dictionary[e.status]} ${e.num.toString().padEnd(8, ' ')}\t ${e.status} `); From bbe3d71c8db384f1c29158a0441ca134793e4d0f Mon Sep 17 00:00:00 2001 From: pasqualespica <36746022+pasqualespica@users.noreply.github.com> Date: Fri, 1 Dec 2023 00:11:27 +0100 Subject: [PATCH 14/15] fix --- report/src/utils/report.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/report/src/utils/report.js b/report/src/utils/report.js index f8473c5f..c300f834 100644 --- a/report/src/utils/report.js +++ b/report/src/utils/report.js @@ -61,18 +61,20 @@ const dictionary = { } -let report_ = '{"title":"","detail":[]}' +// let report_ = '{"title":"","detail":[]}' +let report_ = '{"text":""}' report=JSON.parse(report_); -report.title = `Report ๐Ÿ“ˆ receipt ๐Ÿงพ of ${yesterday_} ๐Ÿง` +report.text = `Report ๐Ÿ“ˆ receipt ๐Ÿงพ of ${yesterday_} ๐Ÿง\n` let p = res.then(function(result) { // console.log(result.resources.forEach(e => { // console.log(`> ${dictionary[e.status]} ${e.num.toString().padEnd(8, ' ')}\t ${e.status} `); // })) let index = 0; result.resources.forEach(e => { - report["detail"].push( {"status": `${dictionary[e.status]} ${e.status}`, "num":`${e.num}` }); + // report["detail"].push( {"status": `${dictionary[e.status]} ${e.status}`, "num":`${e.num}` }); + report.text+=`${dictionary[e.status]} ${e.status} ${e.num.toString().padEnd(8, ' ')}\t ${e.status}\n` }) console.log(JSON.stringify(report)); From 13ec3607c7ac44be8e37113879feb17714be7af1 Mon Sep 17 00:00:00 2001 From: pasqualespica <36746022+pasqualespica@users.noreply.github.com> Date: Fri, 1 Dec 2023 00:17:39 +0100 Subject: [PATCH 15/15] fix --- report/src/utils/report.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/report/src/utils/report.js b/report/src/utils/report.js index c300f834..77a5008f 100644 --- a/report/src/utils/report.js +++ b/report/src/utils/report.js @@ -74,7 +74,7 @@ let p = res.then(function(result) { let index = 0; result.resources.forEach(e => { // report["detail"].push( {"status": `${dictionary[e.status]} ${e.status}`, "num":`${e.num}` }); - report.text+=`${dictionary[e.status]} ${e.status} ${e.num.toString().padEnd(8, ' ')}\t ${e.status}\n` + report.text+=`${dictionary[e.status]} ${e.num.toString().padEnd(8, ' ')}\t ${e.status} \n` }) console.log(JSON.stringify(report));