blob: f7e1ba789d76209f82026e0f2c64a53c422e1e3d [file] [log] [blame]
Zack Williamsbe542312022-06-23 21:51:32 -07001#!/usr/bin/env bash
2
Joey Armstrong518f3572024-02-11 07:56:25 -05003# SPDX-FileCopyrightText: 2022-2024 Open Networking Foundation (ONF) and the ONF Contributors
Zack Williamsbe542312022-06-23 21:51:32 -07004# SPDX-License-Identifier: Apache-2.0
5
6set -eu -o pipefail
7
8echo "git version: $(git --version)"
9
10# Variables used in this and child scripts
11export PUBLISH_URL="charts.opencord.org"
12export OLD_REPO_DIR="cord-charts-repo"
13export NEW_REPO_DIR="chart_repo"
14
15# Configure git
16git config --global user.email "do-not-reply@opennetworking.org"
17git config --global user.name "Jenkins"
18
19# Checkout 'cord-charts-repo' repo that contains updated charts
20git clone "ssh://jenkins@gerrit.opencord.org:29418/$OLD_REPO_DIR.git"
21
22# Clone the `helm-repo-tools` which contains scripts
23git clone ssh://jenkins@gerrit.opencord.org:29418/helm-repo-tools.git
24
25# Setup helm and external repos
26helm repo add stable https://charts.helm.sh/stable
27helm repo add rook-release https://charts.rook.io/release
28helm repo add cord https://charts.opencord.org
29helm repo add elastic https://helm.elastic.co
30helm repo add kiwigrid https://kiwigrid.github.io
31
32# Update the repo
33./helm-repo-tools/helmrepo.sh
34
35# Tag and push to git the charts repo
36pushd "$OLD_REPO_DIR"
37
38 # only update if charts are changed
39 set +e
40 if git diff --exit-code index.yaml > /dev/null; then
41 echo "No changes to charts in patchset $GERRIT_CHANGE_NUMBER on project: $GERRIT_PROJECT, exiting."
42 exit 0
43 fi
44 set -e
45
46 # version tag is the current date in RFC3339 format
47 NEW_VERSION=$(date -u +%Y%m%dT%H%M%SZ)
48
49 # Add changes and create commit
50 git add -A
Eric Balld46914c2024-11-14 16:56:55 -080051 git commit -sm "Changed by CORD Jenkins publish-helm-repo job: $BUILD_NUMBER, for project: $GERRIT_PROJECT, patchset: $GERRIT_CHANGE_NUMBER"
Zack Williamsbe542312022-06-23 21:51:32 -070052
53 # create tag on new commit
54 git tag "$NEW_VERSION"
55
56 echo "Tags including new tag:"
57 git tag -n
58
59 # push new commit and tag back into repo
60 git push origin
61 git push origin "$NEW_VERSION"
62popd
63
64rsync -rvzh --delete-after --exclude=.git "$OLD_REPO_DIR/" "static.opennetworking.org:/srv/sites/$PUBLISH_URL/"