github.com/nilium/gitlab-runner@v12.5.0+incompatible/scripts/dep_status_check (about)

     1  #!/bin/bash
     2  
     3  pkgBuildDir="${1}"
     4  outDir="$(pwd)/out"
     5  reportFile="${outDir}/dep_status"
     6  
     7  mkdir -p "${outDir}"
     8  cd "${pkgBuildDir}"
     9  
    10  dep status -v -old -json > "${reportFile}"
    11  
    12  if [ "$(cat "${reportFile}")" == "[]" ] ; then
    13      exit 0
    14  fi
    15  
    16  jq -C . "${reportFile}"
    17  
    18  #
    19  # Borrowed from https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/support/notify_slack.sh
    20  # and adjusted for our needs:)
    21  #
    22  if [[ -z "${CI_DEP_STATUS_NOTIFY_CHANNEL}" ]] || [[ -z "${CI_DEP_STATUS_NOTIFY_SLACK_WEBHOOK}" ]]; then
    23      echo "Variables CI_DEP_STATUS_NOTIFY_CHANNEL and CI_DEP_STATUS_NOTIFY_SLACK_WEBHOOK are not defined"
    24      echo "Will not send slack notification"
    25  else
    26      messageTmpFile="$(mktemp)"
    27  
    28      cat > "${messageTmpFile}" << EOS
    29  \`dep status\` check for <${CI_PROJECT_URL}> failed. Some dependencies should be updated:
    30  \`\`\`
    31  $(jq -M . "${reportFile}")
    32  \`\`\`
    33  See <${CI_JOB_URL}>
    34  EOS
    35  
    36      message=$(sed -e ':a' -e 'N' -e '$!ba' -e "s/\n/\\\n/g" "${messageTmpFile}")
    37      payload='payload={"channel": "'"${CI_DEP_STATUS_NOTIFY_CHANNEL}"'", "username": "GitLab Runner Dep Status Check", "text": "'"${message//\"/\\\"}"'", "icon_emoji": ":mantelpiece_clock:"}'
    38      curl -X POST -s -L --data-urlencode "${payload}" "${CI_DEP_STATUS_NOTIFY_SLACK_WEBHOOK}"
    39  fi
    40  
    41  exit 1