Skip to content

Instantly share code, notes, and snippets.

@raulneis
Last active June 29, 2018 14:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raulneis/6c45439012907cb4f13a9173ac4d33c6 to your computer and use it in GitHub Desktop.
Save raulneis/6c45439012907cb4f13a9173ac4d33c6 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# This script sets a parameter with the git tag that was
# just checked out (this is a post-checkout hook).
# If there is no tag, the parameter is set with the current
# branch name + the HEAD hash.
# Place this file into .git/hooks/ and chmod +x it.
set -e
# This is the parameters.yml parameter to look for
VERSION=version
tag=$(git tag --points-at HEAD)
if [ "$tag" == "" ]; then
tag="$(git rev-parse --abbrev-ref HEAD)-$(git rev-parse HEAD)"
fi;
sed -i -E s/$VERSION:\ .+/$VERSION:\ $tag/g app/config/parameters.yml
@matudelatower
Copy link

matudelatower commented Jun 25, 2018

in .env

#!/usr/bin/env bash
# This script sets a parameter with the git tag that was
# just checked out (this is a post-checkout hook).
# If there is no tag, the parameter is set with the current
# branch name + the HEAD hash.
# Place this file into .git/hooks/ and chmod +x it.

set -e

# This is the .env parameter to look for
VERSION=APP_VERSION


tag=$(git tag --points-at HEAD)
if [ "$tag" == "" ]; then
    tag="$(git rev-parse --abbrev-ref HEAD)-$(git rev-parse HEAD)"
fi;

sed -i -E s/$VERSION=.+/$VERSION=$tag/g .env

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment