build: Refactor the Minio sync logic and separate the helm chart release

This commit is contained in:
Nikolai Rodionov
2023-03-06 21:42:35 +01:00
committed by Nikolai Rodionov
parent 2eef222b49
commit 5e19dbd9d8
74 changed files with 450 additions and 133 deletions

View File

@ -30,18 +30,40 @@ my $commits = "git fetch && git log --format=format:%H --all";
my @commits_out = `$commits`;
chomp @commits_out;
push @commits_out, 'latest';
# --------------------------------------
# -- Rclone variables
# -------------------------------------
my $dirs = "rclone lsf badhouseplants-minio:/badhouseplants-net";
my @dirs_out = `$dirs`;
chomp @dirs_out;
# ---------------------------------------
# -- Compare builds to commits
# -- And remove obsolete imgages from
# -- registry
# ---------------------------------------
print "Cleaning up the container registry\n";
foreach my $line (@builds_out)
{
if ( ! grep( /^$line$/, @commits_out ) ) {
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";
}
print "Checking if $line is in @commits_out\n\n";
if ( ! grep( /^$line$/, @commits_out ) ) {
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";
}
}
print "Cleaning up Minio\n";
foreach my $line (@dirs_out)
{
print "Checking if $line is in @commits_out\n\n";
chop($line);
if ( ! grep( /^$line$/, @commits_out ) ) {
my $cmd = "rclone purge badhouseplants-minio:/badhouseplants-net/$line";
print "Removing ${line}\n\n";
my $output = `$cmd`;
print "$output \n";
}
}

10
scripts/upload-media.sh Executable file
View File

@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -e
#=== 'prev-commit' solution by o_O Tync
#commit_hash=$(git rev-parse --verify HEAD)
commit=$(git log -1 --pretty="%H%n%ci") # hash \n date
commit_date=$(echo "$commit" | head -2 | tail -1) # 2010-12-28 05:16:23 +0300
commit_hash=$(echo "$commit" | head -1)
echo "$(git rev-parse HEAD)" > /tmp/test
echo "prev_commit='$commit_hash'\ndate='$commit_date'\nbranch='$branch'\n" > /tmp/test.txt