diff options
author | Aaron LI <aly@aaronly.me> | 2018-04-18 16:41:27 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2018-04-18 16:44:09 +0800 |
commit | 053cd1b7fe10f746792e0d1353fad4ad04e8ebe9 (patch) | |
tree | 93137af7af0b073383e0db5ae91cbe301f9bcdd1 /roles/git/templates/cgit | |
parent | f448bcbdf07cf988ab50950df95d822f359041db (diff) | |
download | ansible-dfly-vps-053cd1b7fe10f746792e0d1353fad4ad04e8ebe9.tar.bz2 |
Add git role: host git repos and share repos via cgit
* Host git repositories
* Share git repositories through web interface via cgit
* The static resources used by cgit is also managed/deployed by a git repo ^_^
Diffstat (limited to 'roles/git/templates/cgit')
-rw-r--r-- | roles/git/templates/cgit/cgitrc.j2 | 132 | ||||
-rw-r--r-- | roles/git/templates/cgit/post-receive.j2 | 31 |
2 files changed, 163 insertions, 0 deletions
diff --git a/roles/git/templates/cgit/cgitrc.j2 b/roles/git/templates/cgit/cgitrc.j2 new file mode 100644 index 0000000..f0d83fc --- /dev/null +++ b/roles/git/templates/cgit/cgitrc.j2 @@ -0,0 +1,132 @@ +# +# {{ git.cgit.root }}/cgitrc +# Configuration file for `cgit` served at `code.aaronly.me`. +# See https://git.zx2c4.com/cgit/tree/cgitrc.5.txt +# +# Aaron LI +# 2017-06-19 +# + +# Title and heading of the index page +root-title=Projects from Aaron LI + +# Subheading of the index page +root-desc=The journey is long, but I shall search high and low. + +# More information on the index page +#root-readme={{ git.cgit.root }}/static/about.html + +# File containing the footer that will be included verbatim at +# the bottom of all pages +footer={{ git.cgit.root }}/static/footer.html + + +## +## Static resources (URL configured via Nginx)) +## + +css=/static/cgit.css +logo=/static/logo.png +favicon=/static/favicon.ico + + +## +## Settings +## + +# Root URL for all cgit links +virtual-root=/ + +# Set default clone URL using macro +clone-url=https://git.{{ domains[0].name }}/$CGIT_REPO_URL + +# Allow HTTP transport git clone +enable-http-clone=1 + +# Do NOT show owner on index page +enable-index-owner=0 + +# Show extra links for each repository on the index page +enable-index-links=1 + +# Enable ASCII art commit history graph on the log pages +enable-commit-graph=1 + +# Show number of affected files per commit on the log pages +enable-log-filecount=1 + +# Show number of added/removed lines per commit on the log pages +enable-log-linecount=1 + +# Sort branches by date +branch-sort=age + +# Enable statistics per week, month, and quarter +max-stats=quarter + +# Allow download of tar.bz2 +snapshots=tar.bz2 + + +## +## List of common mimetypes +## + +mimetype.gif=image/gif +mimetype.html=text/html +mimetype.jpg=image/jpeg +mimetype.jpeg=image/jpeg +mimetype.pdf=application/pdf +mimetype.png=image/png +mimetype.svg=image/svg+xml + +# Highlight source code +# Requires `py36-pygments` package +#source-filter=/usr/local/lib/cgit/filters/syntax-highlighting.py +# Requires `highlight` package +source-filter={{ git.cgit.root }}/syntax-highlighting.sh + +# Format markdown, restructuredtext, manpages, text files, and +# html files through the right converters +about-filter=/usr/local/lib/cgit/filters/about-formatting.sh + +# Search for these files in the root of the default branch of +# repositories for coming up with the about page: +readme=:README.md +readme=:readme.md +readme=:README.mkd +readme=:readme.mkd +readme=:README.rst +readme=:readme.rst +readme=:README.html +readme=:readme.html +readme=:README.htm +readme=:readme.htm +readme=:README.txt +readme=:readme.txt +readme=:README +readme=:readme +readme=:INSTALL.md +readme=:install.md +readme=:INSTALL.mkd +readme=:install.mkd +readme=:INSTALL.rst +readme=:install.rst +readme=:INSTALL.html +readme=:install.html +readme=:INSTALL.htm +readme=:install.htm +readme=:INSTALL.txt +readme=:install.txt +readme=:INSTALL +readme=:install + + +## +## Repositories +## + +# NOTE: only the global settings before this directive will be +# applied to each repository. +scan-path={{ git.user.home }}/{{ git.public_dir }} + diff --git a/roles/git/templates/cgit/post-receive.j2 b/roles/git/templates/cgit/post-receive.j2 new file mode 100644 index 0000000..14b455a --- /dev/null +++ b/roles/git/templates/cgit/post-receive.j2 @@ -0,0 +1,31 @@ +#!/bin/sh +# +# post-receive hook for the cgit-static.git repo to checkout the +# resources upon push, a.k.a., deploy on push. +# +# Aaron LI +# 2018-04-18 +# + +GIT_DIR="{{ git.user.home }}/{{ git.cgit.static_repo }}/" +TARGET="{{ git.cgit.root }}/static/" +TARGET_BRANCH="master" + +while read oldrev newrev refname; do + branch=$(git rev-parse --symbolic --abbrev-ref ${refname}) + if [ -n "${branch}" ] && [ "${branch}" = "${TARGET_BRANCH}" ]; then + echo "Deploying cgit static resources ..." + git --work-tree=${TARGET} --git-dir=${GIT_DIR} \ + checkout ${TARGET_BRANCH} -f + + NOW=$(date +"%Y%m%d-%H%M") + git tag release_${NOW} ${TARGET_BRANCH} + + echo " +===============================" + echo " | DEPLOYMENT COMPLETED" + echo " | Target branch: ${TARGET_BRANCH}" + echo " | Target folder: ${TARGET}" + echo " | Tag name : release_${NOW}" + echo " +===============================" + fi +done |