...

Text file src/edge-infra.dev/hack/build/ci/update-manifests.sh

Documentation: edge-infra.dev/hack/build/ci

     1#!/usr/bin/env bash
     2set -eux
     3# This script gets IMGAGE_NAME and TAG as ENV vars, and also gets GITHUB_TOKEN and github_username as secret ENV vars.
     4INFRA_GITHUB_REPOSITORY=${INFRA_GITHUB_REPOSITORY:-"ncrvoyix-swt-retail/edge-infra"}
     5INFRA_BRANCH="${INFRA_BRANCH:-master}"
     6dir=$(basename "$INFRA_GITHUB_REPOSITORY")
     7
     8RELEASE_GITHUB_EMAIL="${RELEASE_GITHUB_EMAIL:-ea230385@corp.ncr.com}"
     9RELEASE_GITHUB_USER=$(echo "$RELEASE_GITHUB_EMAIL" | cut -d'@' -f1)
    10
    11echo "cloning $INFRA_GITHUB_REPOSITORY"
    12dir=$(basename "$INFRA_GITHUB_REPOSITORY")
    13rm -rf "../$dir"
    14git clone -b "$INFRA_BRANCH" "https://$RELEASE_GITHUB_USER:$RELEASE_GITHUB_TOKEN@github.com/$INFRA_GITHUB_REPOSITORY.git" "../$dir"
    15cd "../$dir" || exit
    16
    17edgeadmin cfg update-manifests \
    18    --component "$IMAGE_NAME" \
    19    --image "$IMAGE_NAME=$TAG" \
    20    --manifests "$INFRA_MANIFESTS_DIR"
    21
    22if [ "$DRY_RUN" == 'true' ]; then
    23    git diff
    24    exit 0
    25fi
    26
    27echo "configuring git committer information"
    28git config --global user.email "$RELEASE_GITHUB_EMAIL"
    29git config --global user.name "$RELEASE_GITHUB_USER"
    30
    31echo "committing updated manifests"
    32commit_sha=$(git rev-parse HEAD)
    33url=$(git config --get remote.origin.url | awk -F '@' '{print $2}')
    34url=${url%.*}
    35commit_message="[generated] updating images for $IMAGE_NAME commit: https://$url/commits/$commit_sha"
    36
    37git commit -am "$commit_message"
    38
    39echo "$commit_message"
    40
    41while [ -n "$(git fetch)" ]; do
    42    echo "Working tree is not clean. Pulling latest changes from $INFRA_BRANCH before push."
    43    git pull
    44done
    45
    46git push

View as plain text