Code Monkey home page Code Monkey logo

git_hook's Introduction

Dépôt de test pour les hook git

Créer les dépôts pour tester

Executer soit init_dir_for_test.py soitinit_dir_for_test.sh

Structure du dépot après initialisation

Le repertoire client contient un dépôt git normal avec comme remote origin qui pointe sur le répertoir server qui lui même est un dépot git bare.

Le repertoire hook-py contient des hooks de test écrits en python

Ajout d'un hook post-receive

cp "hook-py/post-receive" "server/.git"

Tester si le script fonction

echo 'test' >> 'client/test' && git -C './client' add . && git -C './client' commit -m "test" -m "body" && git -C './client' push origin

Installation pour un deploiement auto

Sur le serveur

Créer un dépot git bare sur le serveur et mettre le hook post-receive.

git init --bare ~/project.git
curl -L -o ~/project.git/hooks/post-receive https://raw.githubusercontent.com/marc31/git_hook/main/hook-py/post-receive
chmod +x project.git/hooks/post-receive

Il faut modifier les variables dans post-receive :

# Le chemin où les fichiers doivent être déployer sur le serveur
targetDir="../target"      
# Le chemin du dépôt bare
gitBareDir="../server"
# Les branches qui doivent initialiser un déploiement
branchToDeploy=["prod"]

Maintenant sur la machine de dev lorsque l'on veut lancer un déploiement

# Mettre le répertoire courant qui contient ce que l'on veut déployer
cd monrep
# Rajouter un `remote` vers le dépôt bare
git remote add deploy USER@SERVER_BARE_URL:PATH_DU_DEPOT_BARE

Quand on veut deployer il suffit maintenant de faire sur la machine de dev

git push deploy

git_hook's People

Contributors

marc31 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.