├── .editorconfig ├── .travis.yml ├── LICENSE.txt ├── Makefile ├── README.md ├── plugin.toml └── receive-app /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | insert_final_newline = true 5 | indent_style = space 6 | indent_size = 2 7 | 8 | [Makefile] 9 | insert_final_newline = true 10 | indent_style = tab 11 | indent_size = 4 12 | 13 | [*.mk] 14 | insert_final_newline = true 15 | indent_style = tab 16 | indent_size = 4 17 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | language: bash 3 | env: 4 | - DOKKU_VERSION=master 5 | before_install: make setup 6 | script: make test 7 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (C) 2014 cjblomqvist 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | shellcheck: 2 | ifeq ($(shell shellcheck > /dev/null 2>&1 ; echo $$?),127) 3 | ifeq ($(shell uname),Darwin) 4 | brew install shellcheck 5 | else 6 | sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse' 7 | sudo apt-get update -qq && sudo apt-get install -qq -y shellcheck 8 | endif 9 | endif 10 | 11 | bats: 12 | ifeq ($(shell bats > /dev/null 2>&1 ; echo $$?),127) 13 | ifeq ($(shell uname),Darwin) 14 | brew install shellcheck 15 | else 16 | sudo add-apt-repository ppa:duggan/bats --yes 17 | sudo apt-get update -qq && sudo apt-get install -qq -y bats 18 | endif 19 | endif 20 | 21 | ci-dependencies: shellcheck bats 22 | 23 | lint: 24 | # these are disabled due to their expansive existence in the codebase. we should clean it up though 25 | # SC2046: Quote this to prevent word splitting. - https://github.com/koalaman/shellcheck/wiki/SC2046 26 | # SC2068: Double quote array expansions, otherwise they're like $* and break on spaces. - https://github.com/koalaman/shellcheck/wiki/SC2068 27 | # SC2086: Double quote to prevent globbing and word splitting - https://github.com/koalaman/shellcheck/wiki/SC2086 28 | @echo linting... 29 | @$(QUIET) find ./ -maxdepth 1 -not -path '*/\.*' | xargs file | egrep "shell|bash" | awk '{ print $$1 }' | sed 's/://g' | xargs shellcheck -e SC2046,SC2068,SC2086 30 | 31 | setup: 32 | $(MAKE) ci-dependencies 33 | 34 | test: setup lint 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # dokku-git-rev [![Build Status](https://img.shields.io/travis/dokku-community/dokku-git-rev.svg?branch=master "Build Status")](https://travis-ci.org/dokku-community/dokku-git-rev) 2 | 3 | Lets you fetch the git revision hash used to build the app from the `GIT_REV` 4 | 5 | ## requirements 6 | 7 | - dokku 0.4.0+ 8 | - docker 1.8.x 9 | 10 | ## installation 11 | 12 | ```shell 13 | # on 0.3.x 14 | cd /var/lib/dokku/plugins 15 | git clone https://github.com/cjblomqvist/dokku-git-rev.git dokku-git-rev 16 | dokku plugins-install 17 | 18 | # on 0.4.x+ 19 | dokku plugin:install https://github.com/cjblomqvist/dokku-git-rev.git --name dokku-git-rev 20 | ``` 21 | 22 | ## hooks 23 | 24 | This plugin provides hooks: 25 | 26 | * `receive-app`: captures the current `GIT_REV` 27 | 28 | ## usage 29 | 30 | On git deploys, the `GIT_REV` environment variable will be set for your application and be available for your usage. 31 | -------------------------------------------------------------------------------- /plugin.toml: -------------------------------------------------------------------------------- 1 | [plugin] 2 | description = "adds the current git hash as an environment variable" 3 | version = "1.0.0" 4 | [plugin.config] 5 | -------------------------------------------------------------------------------- /receive-app: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x 3 | source "$PLUGIN_AVAILABLE_PATH/config/functions" 4 | 5 | main() { 6 | declare APP="$1" REV="$2" 7 | 8 | # Don't write the revision if there is no git repository. 9 | if [[ -d "$DOKKU_ROOT/$APP/refs" ]]; then 10 | config_set --no-restart "$APP" GIT_REV="$REV" 11 | fi 12 | } 13 | 14 | main "$@" 15 | --------------------------------------------------------------------------------