Skip to content
Snippets Groups Projects
Commit f6f89243 authored by Varac's avatar Varac
Browse files

Merge branch '1204-use-remote-git-url-for-forks' into 'main'

Use local git remote URL for flux

Closes #1204

See merge request !933
parents 80623a05 7ab23c52
No related branches found
No related tags found
2 merge requests!961Release v0.8.1 to v0.8 branch,!933Use local git remote URL for flux
......@@ -13,6 +13,11 @@ stages:
- cluster-health
variables:
# Useful for debugging
# !!! CAREFUL - this will expose private keys in the CI logs !!!
# !!! Make sure to delete the resulting job output from the !!!
# !!! job's output site (Trash can symbol at the top) !!!
# CI_DEBUG_TRACE: "true"
# This decides which branch gets used by the create-vps and install-stackspin
# jobs. It also indirectly influences the commit sha that's checked for in the
# kustomization ready jobs
......
#!/usr/bin/env bash
set -x
set -euo pipefail
# shellcheck source=install/flux-version-check.sh
......@@ -10,9 +11,9 @@ python "$(dirname "$0")/generate_secrets.py" stackspin
# Check if stackspin-cluster-variables secret exists
smtp_password=$(kubectl get secret -n flux-system stackspin-cluster-variables --template '{{.data.outgoing_mail_smtp_password}}' | base64 -d)
smtp_password_urlencoded=$(python -c "import urllib.parse; print(urllib.parse.quote('${smtp_password}', safe=''), end='')" | base64 -w0)
smtp_password_urlencoded=$(python -c "import urllib.parse; print(urllib.parse.quote('$smtp_password', safe=''), end='')" | base64 -w0)
# Add url-encoded version of password to the cluster
kubectl patch secret -n flux-system stackspin-cluster-variables -p "{\"data\": {\"outgoing_mail_smtp_password_urlencoded\": \"${smtp_password_urlencoded}\"}}"
kubectl patch secret -n flux-system stackspin-cluster-variables -p "{\"data\": {\"outgoing_mail_smtp_password_urlencoded\": \"$smtp_password_urlencoded\"}}"
flux install \
--network-policy=false \
......@@ -35,12 +36,6 @@ kubectl patch deployment \
kustomize-controller \
--patch-file "$(dirname "$0")/flux-patches/kustomize-controller.yaml"
# get current git branch name
branch=${STACKSPIN_BRANCH:-}
[ -z "$branch" ] && branch=$(git rev-parse --abbrev-ref HEAD)
echo "Tracking branch $branch for https://open.greenhost.net/stackspin/stackspin flux repo"
# Create stackspin and stackspin-apps namespaces
kubectl get namespace stackspin 2>/dev/null || kubectl create namespace stackspin
kubectl get namespace stackspin-apps 2>/dev/null || kubectl create namespace stackspin-apps
......@@ -54,8 +49,26 @@ python "$(dirname "$0")/generate_secrets.py" kube-prometheus-stack
python "$(dirname "$0")/generate_secrets.py" prometheus
python "$(dirname "$0")/generate_secrets.py" alertmanager
# get current git branch name
branch=${STACKSPIN_BRANCH:-}
[ "$branch" = "" ] && branch=$(git rev-parse --abbrev-ref HEAD)
# Get current git remote url
remote_url="${CI_MERGE_REQUEST_SOURCE_PROJECT_URL:-}"
if [ "$remote_url" = "" ]; then
# Running locally
remote_name=$(git rev-parse --abbrev-ref --symbolic-full-name "@{u}" | cut -d'/' -f1)
remote_url=$(git remote get-url "$remote_name")
fi
# In case the remote URL is a git: URL, transform it to a https-url
if [[ $remote_url == "git@"* ]]; then
remote_url=$(echo "$remote_url" | sed 's|:|/|; s|^git@|https://|; s|.git$||')
fi
echo "Tracking branch $branch for $remote_url flux repo"
flux create source git stackspin \
--url=https://open.greenhost.net/stackspin/stackspin \
--url="$remote_url" \
--branch="$branch" \
--interval=1h
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment