feat: Add a script for pushing images to the bucket

build: Update the CI

fix: Update the sctipt so it creates correct dirs
This commit is contained in:
Nikolai Rodionov
2023-03-29 18:13:55 +02:00
parent 80cb94f767
commit 4e1fa24a21
6 changed files with 73 additions and 32 deletions

18
scripts/upload-media.pl Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/perl
my $git_branch = `git rev-parse --abbrev-ref HEAD`;
my $git_commit_sha = `git rev-parse HEAD`;
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);
if ( $git_branch eq $main_branch) {
print "Syncing to the production bucket\n";
print `rclone sync -P "$common_bucket/$git_commit_sha" "$main_bucket/"`;
} else {
print "Creating a new hashed dir in the common bucket\n";
print `rclone copy -P static "$common_bucket/$git_commit_sha"`;
}

View File

@ -1,10 +0,0 @@
#!/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