From 1f3496d13a735fe8f45d334a63592e0bc39d6e53 Mon Sep 17 00:00:00 2001 From: Nikolai Rodionov Date: Sun, 26 Feb 2023 10:06:41 +0100 Subject: [PATCH] fix: badge and add an annotation to istio resource --- chart/templates/deployment.yaml | 5 ++++ config.yaml | 1 + content/about/_index.md | 5 ++-- kube/main.yaml | 6 +++++ kube/template.yaml | 3 +++ scripts/cleanup.pl | 42 +++++++++++++++++++++++---------- 6 files changed, 47 insertions(+), 15 deletions(-) diff --git a/chart/templates/deployment.yaml b/chart/templates/deployment.yaml index e1d83fd..0301c5c 100644 --- a/chart/templates/deployment.yaml +++ b/chart/templates/deployment.yaml @@ -46,6 +46,11 @@ spec: resources: {{- toYaml .Values.rclone.container.resources | nindent 12 }} - name: {{ .Values.hugo.container.name }} + env: + {{- range $key, $value := .Values.hugo.env}} + - key: {{ $key }} + value: {{ $value }} + {{- end}} args: - --baseURL - {{ .Values.hugo.baseURL }} diff --git a/config.yaml b/config.yaml index b04b5ae..0a5b237 100644 --- a/config.yaml +++ b/config.yaml @@ -22,6 +22,7 @@ menu: taxonomies: tag: tags params: + GitBranch: main ShowBreadCrumbs: true ShowReadingTime: true ShowPostNavLinks: true diff --git a/content/about/_index.md b/content/about/_index.md index bcf2e1a..f15ca6d 100644 --- a/content/about/_index.md +++ b/content/about/_index.md @@ -6,9 +6,10 @@ draft: false > It was supposed to be just yet another web page with musical releases reviews, but after trying to write something about them, I've found out that I'm not good at it. So it's just a blog where I'm talking about everything that comes to my mind. -[![Build Status](https://drone.badhouseplants.net/api/badges/allanger/badhouseplants-net/status.svg?ref=refs/heads/main)](https://drone.badhouseplants.net/allanger/badhouseplants-net/latest) - +[![Build Status](https://drone.badhouseplants.net/api/badges/badhouseplants/badhouseplants-net/status.svg?ref=refs/heads/{{< param GitBranch >}})](https://drone.badhouseplants.net/badhouseplants/badhouseplants-net) + +{{< param GitBranch >}} ### Who am I? > If you're hiring, you can find [my CV here]({{< ref "cv" >}} ) diff --git a/kube/main.yaml b/kube/main.yaml index bbf1286..d73d4c2 100644 --- a/kube/main.yaml +++ b/kube/main.yaml @@ -4,6 +4,12 @@ chart_version: $ARGO_APP_CHART_VERSION repo_url: https://git.badhouseplants.net/api/packages/badhouseplants/helm value: | + namespace: hugo: image: tag: $ARGO_APP_IMAGE_TAG + istio: + annotations: + link.argocd.argoproj.io/env: https://badhouseplants.net/ + link.argocd.argoproj.io/build: $DRONE_BUILD_LINK + diff --git a/kube/template.yaml b/kube/template.yaml index e2c6318..2562c6d 100644 --- a/kube/template.yaml +++ b/kube/template.yaml @@ -10,6 +10,9 @@ istio: hosts: - $ARGO_APP_HOSTNAME + annotations: + link.argocd.argoproj.io/env: https://$ARGO_APP_HOSTNAME/ + link.argocd.argoproj.io/build: $DRONE_BUILD_LINK hugo: image: tag: $ARGO_APP_IMAGE_TAG diff --git a/scripts/cleanup.pl b/scripts/cleanup.pl index 67d317e..2043562 100755 --- a/scripts/cleanup.pl +++ b/scripts/cleanup.pl @@ -1,32 +1,48 @@ #!/usr/bin/perl -# Modules used use strict; use warnings; -use Carp; - - +# -------------------------------------- +# -- Drone variables +# -------------------------------------- my $drone_url="$ENV{'DRONE_SYSTEM_PROTO'}://$ENV{'DRONE_SYSTEM_HOST'}"; my $drone_project=$ENV{'DRONE_REPO'}; my $drone_api="$drone_url/api/repos/$drone_project/builds"; +# -------------------------------------- +# -- Gitea variables +# -------------------------------------- +my $gitea_url=$ENV{'GITEA_URL'} || 'https://git.badhouseplants.net/api/v1'; +my $gitea_org=$ENV{'GITEA_ORG'} || 'badhouseplants'; +my $gitea_package=$ENV{'GITEA_PACKAGE'} || 'badhouseplants-net'; +my $gitea_api="$gitea_url/packages/$gitea_org/container/$gitea_package"; my $gitea_token=$ENV{'GITEA_TOKEN'}; -my $commits = "git log --format=format:%H --all"; -my @commits_out = `$commits`; -chomp @commits_out; -push @commits_out, 'latest'; - +my $gitea_user=$ENV{'GITEA_USER'} || $ENV{'DRONE_COMMIT_AUTHOR'}; +# --------------------------------------- +# -- Get recent builds from drone-ci +# --------------------------------------- my $builds = "curl -X 'GET' $drone_api -H 'accept: application/json' | jq -r '.[].after'"; my @builds_out = `$builds`; chomp @builds_out; +# --------------------------------------- +# -- Get a list of all commits + 'latest' +# --------------------------------------- +my $commits = "git log --format=format:%H --all"; +my @commits_out = `$commits`; +chomp @commits_out; +push @commits_out, 'latest'; - +# --------------------------------------- +# -- Compare builds to commits +# -- And remove obsolete imgages from +# -- registry +# --------------------------------------- foreach my $line (@builds_out) { - print $line; if ( ! grep( /^$line$/, @commits_out ) ) { - my $cmd = "curl -X 'DELETE' \"https://git.badhouseplants.net/api/v1/packages/badhouseplants/container/badhouseplants-net/${line}\" -H 'accept: application/json' -u allanger:$gitea_token || true"; - print "Removing ${line}\n"; + my $cmd = "curl -X 'DELETE' -s \"$gitea_api/$line\" -H 'accept: application/json' -u $gitea_user:$gitea_token || true"; + print "Removing ${line}\n\n"; my $output = `$cmd`; + print "$output \n"; } }