aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/deploy.pl
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-05-29 15:22:24 +0100
committerMatthew Lemon <y@yulqen.org>2024-05-29 15:22:24 +0100
commit8e4381daeba028f4f6069566a78a22f1add57eda (patch)
tree247d572238bd2708db0e38c6588ff8da8d161fab /scripts/deploy.pl
parentdc17e00e62a7f9d090b95601467765d1f613f572 (diff)
Started work on a Perl script to check/assit with deployment
Diffstat (limited to 'scripts/deploy.pl')
-rw-r--r--scripts/deploy.pl34
1 files changed, 34 insertions, 0 deletions
diff --git a/scripts/deploy.pl b/scripts/deploy.pl
new file mode 100644
index 0000000..81f3957
--- /dev/null
+++ b/scripts/deploy.pl
@@ -0,0 +1,34 @@
+#!/usr/bin/env -S perl -w
+
+use warnings;
+use strict;
+
+# Get environment variables from .env file
+print "The .env-prod file is critical for the deployment.\n";
+print ".env file exists in the project directory.\n" if -e "../.env";
+print "It contains the following environment variables:\n\n";
+
+my $live_db_url;
+my $commented_db_url;
+
+open my $envf, "<", "../.env" or die "Cannot open .env file: $!";
+while ( my $line = <$envf>) {
+ # TODO fix this regex - it will omit commented lines to start with
+ if ($line =~ /^[A-Z_]+=/) {
+ if ($line =~ /^DATABASE_URL/) {
+ my @live_url = split(/=/, $line);
+ $live_db_url = $live_url[1];
+ }
+ if ($line =~ /^#DATABASE_URL/) {
+ my @commented_url = split(/=/, $line);
+ $commented_db_url = $commented_url[1];
+ }
+ print $line;
+ }
+}
+
+print "\n\nDATABASE_URL is $live_db_url";
+print "\n\nCommented DATABASE_URL is $commented_db_url" if defined;
+
+
+close($envf);