-
Notifications
You must be signed in to change notification settings - Fork 0
43 lines (39 loc) · 1.58 KB
/
delete-kots-channel.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
name: Branch Deleted
on: delete
env:
REPLICATED_CLI_VERSION: 0.40.1
REPLICATED_API_TOKEN: ${{ secrets.REPLICATED_API_TOKEN }}
REPLICATED_APP: ${{ secrets.REPLICATED_APP }}
jobs:
delete:
if: github.event.ref_type == 'branch'
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Install Replicated CLI
run: |
curl -sL https://github.com/replicatedhq/replicated/releases/download/v${{ env.REPLICATED_CLI_VERSION }}/replicated_${{ env.REPLICATED_CLI_VERSION }}_linux_amd64.tar.gz -o replicated.tar.gz
tar xf replicated.tar.gz replicated && rm replicated.tar.gz
mv replicated /usr/local/bin/replicated
- name: Delete replicated license
run: |
CUSTOMER_ID=$(replicated customer ls | grep ${{ github.event.ref }} | awk '{print $1}')
if [ "${CUSTOMER_ID}" = "" ]; then
echo "No license found"
exit 0
fi
curl --request POST \
--url https://api.replicated.com/vendor/v3/customer/${CUSTOMER_ID}/archive \
--header 'Authorization: ${{ env.REPLICATED_API_TOKEN }}'
- name: Delete Replicated channel
run: |
CHANNEL_ID=$(replicated channel inspect ${{ github.event.ref }} \
| grep "ID:" \
| sed "s/ID://" \
| sed "s/ //g" || true)
if [ "${CHANNEL_ID}" = "" ]; then
echo "No channel found"
exit 0
fi
# Allowed to fail if customers on channel - this will need to be manually deleted
replicated channel rm "${CHANNEL_ID}" || true