From 2d206df11c49cdd2cc19a52ebbd0fbc6173313df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=ABss=20Treinis?= Date: Sun, 25 Jul 2021 16:40:31 +0200 Subject: [PATCH] Allow to deploy from non-default repo and branch Closes #6 --- Makefile | 4 +++- kafe.lua | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index a7dffc0..1346c85 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,8 @@ ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) CURRENT_UID := $(shell id -u) CURRENT_GID := $(shell id -g) +TARGET_REPO ?= "git@github.com:AlmaLinux/almalinux.org.git" +TARGET_BRANCH ?= "master" .PHONY: default default: dev ; @@ -56,7 +58,7 @@ assemble: # INTERNAL: assemble deployment asset for deployment rm -rf tmp/deploy_out mkdir -p tmp mkdir -p tmp/deploy_out - git clone git@github.com:AlmaLinux/almalinux.org.git tmp/deploy + git clone ${TARGET_REPO} tmp/deploy --branch ${TARGET_BRANCH} # Use local install .venv and node_modules to reuse local install as sort of a cache cp -R .venv tmp/deploy cp -R frontend/node_modules tmp/deploy/frontend diff --git a/kafe.lua b/kafe.lua index 9b03cac..366014f 100644 --- a/kafe.lua +++ b/kafe.lua @@ -6,14 +6,25 @@ k.require_api(1) k.add_inventory('deploy', '18.213.64.210', 22, 'staging', 'website') k.add_inventory('deploy', '3.210.88.35', 22, 'production', 'website') -k.task('deploy', function() +k.task('deploy', function(repo, branch) local version = os.time(os.date('!*t')) k.define('deploy_to', '/opt/almalinux.org') k.define('public', '/var/www/almalinux.org') k.define('version', version) - k.local_shell('make assemble') + if repo == nil then + repo = 'git@github.com:AlmaLinux/almalinux.org.git' + end + + if branch == nil then + branch = 'master' + end + + k.define('repo', repo) + k.define('branch', branch) + + k.local_shell('TARGET_REPO={{repo}} TARGET_BRANCH={{branch}} make assemble') local deploy = function() k.within('{{deploy_to}}')