From 514af66cc3cfa44bc6dca98c625647a698f7f9cf Mon Sep 17 00:00:00 2001 From: jaseg Date: Mon, 16 Aug 2021 13:45:05 +0200 Subject: Add auto-deploy for blog.jaseg.de --- gitolite-site-deploy-hook.sh | 8 ++++++++ gitolite.rc | 4 ++-- setup_git.yml | 24 ++++++++++++++++++++++++ setup_webserver.yml | 7 +++++++ 4 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 gitolite-site-deploy-hook.sh diff --git a/gitolite-site-deploy-hook.sh b/gitolite-site-deploy-hook.sh new file mode 100644 index 0000000..2c34513 --- /dev/null +++ b/gitolite-site-deploy-hook.sh @@ -0,0 +1,8 @@ +#!/bin/sh +echo "[deploy] Checking out static files to blog.jaseg.de webdir..." +echo -n "Checkout is initialized: " +env GIT_WORK_TREE=/var/www/blog.jaseg.de git rev-parse --is-inside-work-tree || git worktree add --detach /var/www/blog.jaseg.de deploy +umask 0002 +env GIT_WORK_TREE=/var/www/blog.jaseg.de git checkout -f deploy +git symbolic-ref HEAD refs/head/main +echo "[deploy] done." diff --git a/gitolite.rc b/gitolite.rc index 2c1169b..c94cbdf 100644 --- a/gitolite.rc +++ b/gitolite.rc @@ -74,7 +74,7 @@ # suggested locations for site-local gitolite code (see cust.html) # this one is managed directly on the server - # LOCAL_CODE => "$ENV{HOME}/local", + LOCAL_CODE => "$ENV{HOME}/local", # or you can use this, which lets you put everything in a subdirectory # called "local" in your gitolite-admin repo. For a SECURITY WARNING @@ -164,7 +164,7 @@ # 'cgit', # allow repo-specific hooks to be added - # 'repo-specific-hooks', + 'repo-specific-hooks', # performance, logging, monitoring... diff --git a/setup_git.yml b/setup_git.yml index 2f4c59f..4cad914 100644 --- a/setup_git.yml +++ b/setup_git.yml @@ -108,6 +108,30 @@ group: gitolite3 mode: 0600 +- name: Create gitolite hook dir + file: + path: /var/lib/gitolite3/local/hooks/repo-specific + state: directory + owner: gitolite3 + group: gitolite3 + mode: 0755 + +- name: Copy blog.jaseg.de git deployment script + copy: + src: gitolite-site-deploy-hook.sh + dest: /var/lib/gitolite3/local/hooks/repo-specific + owner: gitolite3 + group: gitolite3 + mode: 0755 + +- name: Create blog content dir + file: + path: /var/www/blog.jaseg.de + state: directory + owner: nginx + group: gitolite3 + mode: 0570 + - name: Query system user account info getent: database: passwd diff --git a/setup_webserver.yml b/setup_webserver.yml index 4711ad0..552711f 100644 --- a/setup_webserver.yml +++ b/setup_webserver.yml @@ -24,6 +24,13 @@ - openjscad.jaseg.net - automation.jaseg.de +- name: Create blog content dir + file: + path: /var/www/blog.jaseg.de + state: directory + owner: nginx + mode: 0550 + - name: Copy uwsgi systemd socket config copy: src: uwsgi-app@.socket -- cgit