Branch Deleted #383
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |