Fix identation for redis password in preflight check #119
Workflow file for this run
This file contains 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: Delete Branch Changes | |
on: | |
pull_request: | |
types: [closed, unlabeled] # Trigger on close and unlabel events in pull requests | |
jobs: | |
delete-changes: | |
timeout-minutes: 3 | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Replicated CLI | |
shell: bash | |
run: | | |
curl -s https://api.github.com/repos/replicatedhq/replicated/releases/latest \ | |
| grep "browser_download_url.*linux_amd64.tar.gz" \ | |
| cut -d : -f 2,3 \ | |
| tr -d \" \ | |
| wget -O replicated.tar.gz -qi - | |
tar xf replicated.tar.gz replicated && rm replicated.tar.gz | |
mv replicated /usr/local/bin/replicated | |
- name: Generate channel name | |
id: generate-channel-info | |
shell: bash | |
run: | | |
GITHUB_BRANCH_NAME=${GITHUB_HEAD_REF} | |
# Cleaning refs/*/ | |
# refs/whatever/main => main | |
export GITHUB_BRANCH_NAME=${GITHUB_BRANCH_NAME#refs/[a-z]*/} | |
# Normalize image tags characters | |
# my-branch/test-01 => my-branch_test-01 | |
export NORMALIZED_GIT_BRANCH_NAME=${GITHUB_BRANCH_NAME//[^[:alnum:]]/_} | |
# To lowercase all characters | |
export NORMALIZED_GIT_BRANCH_NAME=${NORMALIZED_GIT_BRANCH_NAME,,} | |
# Set maximum 128 characters for image name | |
export NORMALIZED_GIT_BRANCH_NAME=${NORMALIZED_GIT_BRANCH_NAME:0:127} | |
# Share the variable for further steps | |
echo "channel-name=${NORMALIZED_GIT_BRANCH_NAME}" >> "$GITHUB_OUTPUT" | |
echo "version=$(yq .version -r chart/Chart.yaml)" >> "$GITHUB_OUTPUT" | |
- name: Check if channel assigned to PR exists | |
id: check-if-channel-exists | |
shell: bash | |
env: | |
REPLICATED_APP: carto | |
REPLICATED_API_TOKEN: ${{ secrets.REPLICATED_API_TOKEN }} | |
run: | | |
set -eu | |
CHANNEL_DELETE_REQUIRED="false" | |
if replicated channel ls | grep -q ${{ steps.generate-channel-info.outputs.channel-name }}; then | |
CHANNEL_DELETE_REQUIRED="true" | |
CHANNEL_ID=$(replicated channel ls | grep ${{ steps.generate-channel-info.outputs.channel-name }} | awk '{print $1}') | |
echo "Detected channel ID: $CHANNEL_ID. Deleting channel..." | |
echo "channel-id=${CHANNEL_ID}" >> "$GITHUB_OUTPUT" | |
fi | |
echo "channel-exists=${CHANNEL_DELETE_REQUIRED}" >> ${GITHUB_OUTPUT} | |
- name: Unassign customers from channel | |
if: steps.check-if-channel-exists.outputs.channel-exists == 'true' | |
shell: bash | |
env: | |
REPLICATED_APP: carto | |
REPLICATED_API_TOKEN: ${{ secrets.REPLICATED_API_TOKEN }} | |
run: | | |
set -eu | |
echo "::group::Updating customers to Stable channel" | |
# Get the customers list and avoid script failure if no matches found | |
CUSTOMERS=$(replicated customer ls | grep "${{ steps.generate-channel-info.outputs.channel-name }}" || true) | |
# Check if CUSTOMERS is empty | |
if [ -z "$CUSTOMERS" ]; then | |
echo "No customers found for the specified channel." | |
else | |
echo "Updating the following customers:" | |
echo "$CUSTOMERS" | |
while IFS= read -r customer; do | |
CUSTOMER_ID=$(echo $customer | awk '{print $1}') | |
CUSTOMER_NAME=$(echo $customer | awk '{print $2}') | |
echo "Updating customer $CUSTOMER_NAME to Stable channel" | |
replicated customer update \ | |
--channel "Stable" \ | |
--name "${CUSTOMER_NAME}" \ | |
--customer "${CUSTOMER_ID}" | |
echo "Customer $CUSTOMER_NAME updated to Stable channel" | |
done <<< "$CUSTOMERS" | |
fi | |
echo "::endgroup::" | |
- name: Delete channel | |
if: steps.check-if-channel-exists.outputs.channel-exists == 'true' | |
shell: bash | |
env: | |
REPLICATED_APP: carto | |
REPLICATED_API_TOKEN: ${{ secrets.REPLICATED_API_TOKEN }} | |
run: | | |
replicated channel rm ${{ steps.check-if-channel-exists.outputs.channel-id }} |