From 8c094c6ef1a646c8ba10b18cddaa06e1fbfe4617 Mon Sep 17 00:00:00 2001 From: Sarah GLINER Date: Tue, 7 Nov 2023 09:56:35 +0100 Subject: [PATCH] Add url to slack messages --- .github/workflows/build_all.yml | 5 ++++- .github/workflows/refresh_inputs.yml | 4 ++++ .github/workflows/scan_all.yml | 5 ++++- .github/workflows/test_all.yml | 5 ++++- scripts/output_scripts/slack.py | 3 +++ 5 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_all.yml b/.github/workflows/build_all.yml index 4cfab1e..8260499 100644 --- a/.github/workflows/build_all.yml +++ b/.github/workflows/build_all.yml @@ -585,9 +585,12 @@ jobs: python3 scripts/output_scripts/convert.py --input_file full_build_output.json --output_file out.md --key build cat out.md >> $GITHUB_STEP_SUMMARY + - name: Echo GHA url + run: echo "url"=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} >> $GITHUB_ENV + - name: Convert to slack json run: | - python3 scripts/output_scripts/slack.py --input_file full_build_output.json --output_file slack.json --key build --devices ${{ needs.setup-devices.outputs.names }} + python3 scripts/output_scripts/slack.py --input_file full_build_output.json --output_file slack.json --key build --devices ${{ needs.setup-devices.outputs.names }} --url ${{ env.url }} - name: Send custom JSON data to Slack workflow if: ${{ github.event_name == 'schedule' || inputs.send_to_slack == true }} diff --git a/.github/workflows/refresh_inputs.yml b/.github/workflows/refresh_inputs.yml index b2c4b23..04d34bf 100644 --- a/.github/workflows/refresh_inputs.yml +++ b/.github/workflows/refresh_inputs.yml @@ -49,6 +49,9 @@ jobs: else echo "Files are the same!" fi + - name: Echo GHA url + run: echo "url"=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} >> $GITHUB_ENV + - name: Send custom JSON data to Slack workflow if: ${{ failure() && (github.event_name == 'schedule' || inputs.send_to_slack == true) }} id: slack @@ -60,6 +63,7 @@ jobs: "title": "Check input list", "status": ":red-cross: Fail", "status_detail": ":alert: Please update input file ! " + "url": "${{ env.url }}" } env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.github/workflows/scan_all.yml b/.github/workflows/scan_all.yml index 7060ac0..5802697 100644 --- a/.github/workflows/scan_all.yml +++ b/.github/workflows/scan_all.yml @@ -562,9 +562,12 @@ jobs: python3 scripts/output_scripts/convert.py --input_file full_scan_output.json --output_file out.md --key scan cat out.md >> $GITHUB_STEP_SUMMARY + - name: Echo GHA url + run: echo "url"=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} >> $GITHUB_ENV + - name: Convert to slack json run: | - python3 scripts/output_scripts/slack.py --input_file full_scan_output.json --output_file slack.json --key scan --devices ${{ needs.setup-devices.outputs.names }} + python3 scripts/output_scripts/slack.py --input_file full_scan_output.json --output_file slack.json --key scan --devices ${{ needs.setup-devices.outputs.names }} --url ${{ env.url }} - name: Send custom JSON data to Slack workflow if: ${{ github.event_name == 'schedule' || inputs.send_to_slack == true }} diff --git a/.github/workflows/test_all.yml b/.github/workflows/test_all.yml index c1c94d7..538333b 100644 --- a/.github/workflows/test_all.yml +++ b/.github/workflows/test_all.yml @@ -354,9 +354,12 @@ jobs: python scripts/output_scripts/convert.py --input_file test_output.json --output_file out.md --key test cat out.md >> $GITHUB_STEP_SUMMARY + - name: Echo GHA url + run: echo "url"=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} >> $GITHUB_ENV + - name: Convert to slack json run: | - python scripts/output_scripts/slack.py --input_file test_output.json --output_file slack.json --key test + python scripts/output_scripts/slack.py --input_file test_output.json --output_file slack.json --key test --url ${{ env.url }} - name: Send custom JSON data to Slack workflow if: ${{ github.event_name == 'schedule' || inputs.send_to_slack == true }} diff --git a/scripts/output_scripts/slack.py b/scripts/output_scripts/slack.py index daa761c..cea4bd1 100644 --- a/scripts/output_scripts/slack.py +++ b/scripts/output_scripts/slack.py @@ -71,6 +71,7 @@ def count_status(json_list, key): parser.add_argument("--output_file", required=False, type=Path) parser.add_argument("--key", required=False, type=str, default="build") parser.add_argument("--devices", required=False, type=str) + parser.add_argument("--url", required=False, type=str) args = parser.parse_args() @@ -115,6 +116,8 @@ def count_status(json_list, key): if status_detail: slack_json["status_detail"] = status_detail + slack_json["url"] = args.url + if args.output_file: with open(args.output_file, 'w') as f: json.dump(slack_json, f, indent=1)