Use a custom image for building and more scripts
This commit is contained in:
32
scripts/build-container.pl
Executable file
32
scripts/build-container.pl
Executable file
@ -0,0 +1,32 @@
|
||||
#! /usr/bin/perl
|
||||
use strict;
|
||||
use warnings;
|
||||
# -------------------------------------------------
|
||||
# -- Setup Git variables
|
||||
# -------------------------------------------------
|
||||
my $git_branch = `git rev-parse --abbrev-ref HEAD`;
|
||||
my $git_commit_sha = `git rev-parse HEAD`;
|
||||
my $main_branch = "main";
|
||||
chomp($git_branch);
|
||||
chomp($git_commit_sha);
|
||||
# -------------------------------------------------
|
||||
# -- Build the image with SHA tag
|
||||
# -------------------------------------------------
|
||||
my $container_registry = $ENV{'CONTAINER_REGISTRY'} || 'git.badhouseplants.net';
|
||||
my $image_name = $ENV{'DRONE_REPO'} || "badhouseplants/badhouseplants-net";
|
||||
my $tag = "$container_registry/$image_name:$git_commit_sha";
|
||||
my $username = $ENV{'DRONE_USERNAME'} || "allanger";
|
||||
my $password = $ENV{'GITEA_TOKEN'} || "YOU NOT AUTHORIZED, PAL";
|
||||
print `buildah login --username $username --password $password $container_registry` or die;
|
||||
print `buildah build -t $tag .` or die;
|
||||
print `buildah push $tag` or die;
|
||||
# -------------------------------------------------
|
||||
# -- Push the lates if the branch is main
|
||||
# -------------------------------------------------
|
||||
if ( $git_branch eq $main_branch) {
|
||||
my $latest_tag = "$container_registry/$image_name:latest";
|
||||
print `buildah tag $tag $latest_tag` or die;
|
||||
print `buildah push $latest_tag` or die;
|
||||
}
|
||||
|
||||
print "Thanks!\n";
|
@ -1,6 +0,0 @@
|
||||
#! /usr/bin/perl
|
||||
my $commits = "argocd app list -o yaml -l application=badhouseplants | yq '.[].metadata.labels.commit_sha'";
|
||||
my @commits_out = `$commits`;
|
||||
chomp @commits_out;
|
||||
push @commits_out, 'latest';
|
||||
print "@commits_out";
|
@ -15,7 +15,7 @@ my $gitea_user=$ENV{'GITEA_USER'} || $ENV{'DRONE_COMMIT_AUTHOR'};
|
||||
# ---------------------------------------
|
||||
# -- Get tags from Gitea
|
||||
# ---------------------------------------
|
||||
my $builds = "curl -X 'GET' \"$gitea_list_api\" -H 'accept: application/json' -H \"Authorization: token $gitea_token\" | jq '.[].version'";
|
||||
my $builds = "curl -X 'GET' \"$gitea_list_api\" -H 'accept: application/json' -H \"Authorization: token $gitea_token\" | jq -r '.[].version'";
|
||||
my @builds_out = `$builds`;
|
||||
chomp @builds_out;
|
||||
# ---------------------------------------
|
||||
|
27
scripts/deploy-app.pl
Executable file
27
scripts/deploy-app.pl
Executable file
@ -0,0 +1,27 @@
|
||||
#! /usr/bin/perl
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my $chart_version = `cat chart/Chart.yaml | yq '.version'` or die;
|
||||
chomp($chart_version);
|
||||
|
||||
my $git_branch = `git rev-parse --abbrev-ref HEAD`;
|
||||
chomp($git_branch);
|
||||
my $git_commit_sha = `git rev-parse HEAD`;
|
||||
chomp($git_commit_sha);
|
||||
my $main_branch = "main";
|
||||
|
||||
print
|
||||
print $chart_version;
|
||||
# - kubectl get -f ./kube/applicationset.yaml -o yaml > /tmp/appset.yaml
|
||||
# - yq -i "del(.metadata.resourceVersion)" /tmp/appset.yaml
|
||||
# - yq -i "del(.metadata.generation)" /tmp/appset.yaml
|
||||
# - yq -i "del(.metadata.uid)" /tmp/appset.yaml
|
||||
# - yq -i "del(.status)" /tmp/appset.yaml
|
||||
# - yq -i "del(.spec.generators[].list.elements[] | select(.branch == \"$ARGO_APP_BRANCH\"))" /tmp/appset.yaml
|
||||
# - yq -i "del(.spec.generators[].list.elements[] | select(.commit_sha == \"$ARGO_APP_IMAGE_TAG\"))" /tmp/appset.yaml
|
||||
# - yq -i '. *= load("./kube/applicationset.yaml")' /tmp/appset.yaml
|
||||
# - envsubst < ./kube/main.yaml > /tmp/elements.yaml
|
||||
# - yq -i '.spec.generators[].list.elements += load("/tmp/elements.yaml")' /tmp/appset.yaml
|
||||
# - kubectl apply -f /tmp/appset.yaml
|
||||
#
|
@ -5,13 +5,23 @@ my $main_branch = "main";
|
||||
my $common_bucket = "badhouseplants-minio:/badhouseplants-net";
|
||||
my $main_bucket = "badhouseplants-minio:/badhouseplants-net-main";
|
||||
|
||||
chop($git_branch);
|
||||
chop($git_commit_sha);
|
||||
# --------------------------------------------------
|
||||
# -- I'm doing all of it because I can't undestand
|
||||
# -- how not to send 300Mb to the buildah context
|
||||
# --------------------------------------------------
|
||||
chomp($git_branch);
|
||||
chomp($git_commit_sha);
|
||||
|
||||
print `cp -r . /tmp/$git_commit_sha` or die;
|
||||
|
||||
print "Getting the lfs data\n";
|
||||
print `git -C /tmp/$git_commit_sha lfs pull` or die;
|
||||
|
||||
print "Creating a new hashed dir in the common bucket\n";
|
||||
print `rclone copy -P static "$common_bucket/$git_commit_sha"`;
|
||||
|
||||
print `rclone copy -P /tmp/$git_commit_sha/static "$common_bucket/$git_commit_sha"` or die;
|
||||
|
||||
if ( $git_branch eq $main_branch) {
|
||||
print "Syncing to the production bucket\n";
|
||||
print `rclone sync -P "$common_bucket/$git_commit_sha" "$main_bucket/"`;
|
||||
print `rclone sync -P "$common_bucket/$git_commit_sha" "$main_bucket/"` or die;
|
||||
}
|
||||
|
Reference in New Issue
Block a user