# Sample CI workflows for spinning up test instances

**URL:** <https://community.replicated.com/t/sample-ci-workflows-for-spinning-up-test-instances/885>\
**Category:** How do I?\
**Created:** [July 22, 2022, 1:10pm UTC](https://community.replicated.com/t/sample-ci-workflows-for-spinning-up-test-instances/885 "2022-07-22T13:10:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bco](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.replicated.com/bco/32/482_2.png) [@bco](https://community.replicated.com/u/bco)\
**Post date:** [July 22, 2022, 1:10pm UTC](https://community.replicated.com/t/sample-ci-workflows-for-spinning-up-test-instances/885/1 "2022-07-22T13:10:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![JulianL](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.replicated.com/julianl/32/498_2.png) [@JulianL](https://community.replicated.com/u/JulianL)\
**Post date:** [July 29, 2022, 6:52am UTC](https://community.replicated.com/t/sample-ci-workflows-for-spinning-up-test-instances/885/2 "2022-07-29T06:52:50Z")

</div>

Hi,

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

```auto
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:

```auto
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.
