From c19dcdc4c446c839bd89b7c78a65ff4372e77665 Mon Sep 17 00:00:00 2001
From: "Alexander V. Tikhonov" <avtikhon@tarantool.org>
Date: Mon, 12 Apr 2021 10:41:27 +0300
Subject: [PATCH] github-ci: fix message send on rhel/fedora hosts

Found that on self-hosted runners where CentOS 7 is the base OS,
'send-telegram-notify' action creates message with syntax error:

  --------------'\n't'\n'```'\n'')) ; \
  ^
  SyntaxError: unexpected character after line continuation character

It happened because of extra quotes at '\n' while it had to be \n.
To avoid of it the same message changes must be done as for OSX
hosts are doing. These changes should be done when self-hosted
runners uses RHEL or Fedora as base OS.
---
 .github/actions/send-telegram-notify/action.yml | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/.github/actions/send-telegram-notify/action.yml b/.github/actions/send-telegram-notify/action.yml
index a5de86ca16..e9b89870dc 100644
--- a/.github/actions/send-telegram-notify/action.yml
+++ b/.github/actions/send-telegram-notify/action.yml
@@ -28,6 +28,12 @@ runs:
         uname -s | tee -a $GITHUB_ENV
         echo 'EOF' >> $GITHUB_ENV
       shell: bash
+    # check if host OS is rhel or fedora
+    - run: |
+        echo 'OS_IS_FEDORA_OR_RHEL<<EOF' >> $GITHUB_ENV
+        grep "^ID=" /etc/os-release | grep -e 'centos' -e 'fedora' && echo true | tee -a $GITHUB_ENV
+        echo 'EOF' >> $GITHUB_ENV
+      shell: bash
     # get job id number
     - run: |
         sudo -n apt update -y ||:
@@ -53,7 +59,7 @@ runs:
       run: |
         # convert message from multi lines to single line and
         # add backslashes to single quote marks in message
-        if ${{ env.KERNEL_NAME == 'Darwin' }} ; then
+        if ${{ env.OS_IS_FEDORA_OR_RHEL == 'true' }} || ${{ env.KERNEL_NAME == 'Darwin' }} ; then
           msg="${MSG//$'\n'/\n}"
           msg="${msg//$'\\\''/\'}"
         else
-- 
GitLab