# Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 parameters: var_name: "" condition: 'True' steps: - bash: | set -euo pipefail TMP=$(mktemp) cat > "$TMP" <<'END' PROJ_DIR="$PWD" escape_slack() { local r r="$1" r="${r//&/&}" r="${r//>/>}" r="${r// "$pr_number" fi } request_pr_review() { local pr_number reviewer pr_number="$1" reviewer="$2" jq -n --arg reviewer "$reviewer" \ '{"reviewers": [$reviewer]}' \ | curl -H "Content-Type: application/json" \ -H "$(get_gh_auth_header)" \ --fail \ --silent \ --location \ -d @- \ "https://api.github.com/repos/digital-asset/daml/pulls/$pr_number/requested_reviewers" } user_slack_handle() { local email sha sha=$1 email=$(git log -n 1 --format=%ae $sha) if cat ci/slack_user_ids | grep $email >/dev/null 2>&1; then echo $(cat ci/slack_user_ids | grep $email | awk '{print $2}') else echo "" fi } tell_slack() { local message channel message="$1" channel=${2:-$(Slack.team-daml)} jq -n --arg message "$message" '{"text": $message}' \ | curl -XPOST -i -H 'Content-Type: application/json' -d @- $channel } wrap_gcloud() ( cred="$1" cmd="$2" key=$(mktemp) config_dir=$(mktemp -d) trap "rm -rf $key $config_dir" EXIT echo "$cred" > $key export CLOUDSDK_CONFIG="$config_dir" export BOTO_CONFIG=/dev/null gcloud auth activate-service-account --key-file=$key eval "$cmd" ) gcs() ( cred="$1" cmd="${@:2}" wrap_gcloud "$cred" "gsutil $cmd" ) setvar() { echo "Setting '$1' to '$2'" echo "##vso[task.setvariable variable=$1;isOutput=true]$2" } next_in_rotation() { awk '/^[^#]/ {print $0}' "$PROJ_DIR/release/rotation" | head -n 1 } next_in_rotation_slack() { next_in_rotation | awk '{print $1}' } next_in_rotation_github() { next_in_rotation | awk '{print $2}' } trigger_azure() ( token=$1 shift build=$1 shift az extension add --name azure-devops trap 'az devops logout' EXIT echo $token \ | az devops login --org "https://dev.azure.com/digitalasset" az pipelines build queue \ --definition-name $build \ --org "https://dev.azure.com/digitalasset" \ --project daml \ $@ ) END echo "##vso[task.setvariable variable=${{parameters.var_name}}]$TMP" displayName: install Bash lib condition: ${{parameters.condition}}