Sample CI workflows for spinning up test instances

Hi,

We’re looking into spinning up test instances in our GitHub Actions jobs for manual & automated testing of our code changes.

Currently our CI job creates a channel for each PR and pushes a release to it. For manual testing we then open the vendor portal, assign our dev customer to a channel and run the install. We would like to automate that process. I think I read somewhere that other customers are working this way by creating a customer in the CI job. Is there any sample workflow available?

Alternatively is it possible to force override the customer’s channel on install with a flag to ‘kots install’,for customer’s with Dev licenses? This would save us the work of creating the channel and writing the scripts to periodically clean up obsolete ones.

Hi,

we create customers on the fly, and it looks something like this:

curl --request GET --get \
  --url "https://api.replicated.com/vendor/v3/app/${APP_ID}/customers" \
  --data-urlencode "customerName=${CUSTOMER_NAME}" \
  --header 'Accept: application/json' \
  --header "Authorization: ${REPLICATED_API_TOKEN}" \
  --output ./customer.json

if jq -e '.customers[0]' ./customer.json > /dev/null; then
  echo "Customer already exists";
else
  curl --request GET --get \
    --url "https://api.replicated.com/vendor/v3/app/${APP_ID}/channels" \
    --data-urlencode "channelName=${CHANNEL_NAME}" \
    --data-urlencode 'excludeDetail=true' \
    --header 'Accept: application/json' \
    --header "Authorization: ${REPLICATED_API_TOKEN}" \
    --output ./get_channel.json

  if jq -e '.channels[0]' ./get_channel.json > /dev/null; then
    export CHANNEL_ID=$(jq -r '.channels[0].id' ./get_channel.json)

    curl --request POST \
      --url https://api.replicated.com/vendor/v3/customer \
      --header 'Accept: application/json' \
      --header 'Content-Type: application/json' \
      --header "Authorization: ${REPLICATED_API_TOKEN}" \
      --fail \
      --output ./customer.json \
      --data "
    {
         \"entitlementValues\": [
              {
                   \"name\": \"YOUR_CUSTOM_LICENSE_KEY\",
                   \"value\": \"YOUR_CUSTOM_LICENSE_VALUE\"
              }
         ],
         \"channel_id\": \"${CHANNEL_ID}\",
         \"app_id\": \"${APP_ID}\",
         \"expires_at\": \"$(date -d '+1 year' '+%FT%TZ')\",
         \"is_snapshot_supported\": true,
         \"name\": \"${CUSTOMER_NAME}\",
         \"type\": \"dev\"
    }
    "
  else
    echo "Channel '${CHANNEL_NAME}' doesn't exist.";
  fi
fi

customer_id=$(jq -r '(.customers[0] // .customer).id' ./customer.json)
echo "Customer ID: ${customer_id}"

During the installation, we download the customer license:

curl --request GET \
                --url "https://api.replicated.com/vendor/v3/app/${APP_ID}/customer/${CUSTOMER_ID}/license-download" \
                --header 'Accept: application/json' \
                --header "Authorization: ${REPLICATED_API_TOKEN}" \
                --output ./license.yml

I hope that helps to get started. We don’t get around a cleanup step, though.

2 Likes