From 7452ef43706da0ae47899e3625ae98b770db2287 Mon Sep 17 00:00:00 2001 From: Jakub Czajka Date: Mon, 19 Jun 2023 17:50:16 +0200 Subject: [PATCH] [cv] Configure automatic deployment and describe the repository. --- cv.git/deploy.yaml | 29 +++++++++++++++++++++++++++++ cv.git/description | 1 + cv.git/hooks/post-receive | 13 +++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 cv.git/deploy.yaml create mode 100644 cv.git/description create mode 100755 cv.git/hooks/post-receive diff --git a/cv.git/deploy.yaml b/cv.git/deploy.yaml new file mode 100644 index 0000000..0cb6ebb --- /dev/null +++ b/cv.git/deploy.yaml @@ -0,0 +1,29 @@ +# Copyright (c) 2023 Jakub Czajka +# License: GPL-3.0 or later. + +- hosts: servers + vars: + dest: "{{ ansible_local.env.vars.prod_dir }}/cv" + repo: "{{ ansible_local.env.vars.git_home_dir }}/cv.git" + tasks: + - name: Install texlive + package: + name: + - texlive + state: latest + become: true + - name: Create destination directory + file: + path: "{{ dest }}" + state: directory + mode: 0775 + owner: git + group: git + become: true + - name: Checkout cv's files to the destination directory + command: /usr/bin/git --work-tree={{ dest }} --git-dir={{ repo }} \ + checkout main --force + become: true + - name: Compile CV + command: /usr/bin/pdflatex --output-directory={{ dest }} {{ dest }}/cv.tex + become: true diff --git a/cv.git/description b/cv.git/description new file mode 100644 index 0000000..813371c --- /dev/null +++ b/cv.git/description @@ -0,0 +1 @@ +Files for generating Curriculum Vitae (CV). diff --git a/cv.git/hooks/post-receive b/cv.git/hooks/post-receive new file mode 100755 index 0000000..ac81bdc --- /dev/null +++ b/cv.git/hooks/post-receive @@ -0,0 +1,13 @@ +#!/bin/sh +# Copyright (c) 2023 Jakub Czajka +# License: GPL-3.0 or later. + +while read old_revision new_revision branch +do + if [ "${branch}" != "refs/heads/main" ] + then + echo "${branch} is not the main branch so not deploying." + exit 0 + fi + sudo /usr/bin/ansible-playbook --connection=local deploy.yaml +done -- 2.39.5