{"id":22526168,"url":"https://github.com/impsdc/continious-developement-git","last_synced_at":"2026-03-19T23:04:05.149Z","repository":{"id":49341605,"uuid":"322960103","full_name":"impsdc/continious-developement-git","owner":"impsdc","description":"Deploy on push with git","archived":false,"fork":false,"pushed_at":"2020-12-19T23:56:15.000Z","size":2,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T04:17:35.332Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/impsdc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-12-19T23:54:57.000Z","updated_at":"2020-12-19T23:56:18.000Z","dependencies_parsed_at":"2022-08-27T07:31:10.031Z","dependency_job_id":null,"html_url":"https://github.com/impsdc/continious-developement-git","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/impsdc/continious-developement-git","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/impsdc%2Fcontinious-developement-git","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/impsdc%2Fcontinious-developement-git/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/impsdc%2Fcontinious-developement-git/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/impsdc%2Fcontinious-developement-git/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/impsdc","download_url":"https://codeload.github.com/impsdc/continious-developement-git/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/impsdc%2Fcontinious-developement-git/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270702562,"owners_count":24630877,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-16T02:00:11.002Z","response_time":91,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-07T06:14:07.926Z","updated_at":"2026-02-08T21:07:05.960Z","avatar_url":"https://github.com/impsdc.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# CONTINIOUS INTEGRATION AVEC GIT\n\nRelou de ssh sur votre server distant pour git pull et restart apache2/nginx à chaque modif ? \nDeployer en un push un projet en configurant un git remote sur votre server distant !\n\n## Prérequis\n\n\n - Avoir un projet pret à être deployer en local\n - Avoir un accès SSH sur un server distant\n\nMon projet d'exemple sera un projet Vue à deployer sur un server AWS ec2 avec Nginx\nIl est possible d'avoir déjà un repository git existant sur votre projet\n\n## 1. Création du dossier de production sur le server distant\n\n\n```\nssh USER@SERVER_HOST\nmkdir ~/DEPLOY-FOLDER\n\nUSER: Utilisateur de votre server distant\nDEPLOY-FOLDER: Dossier que vous allez faire pointer sur votre nom de domaine\n```\n\n## 2. Création du repository dans le server distant\n\n\n```\nmkdir ~/BARE-DEPLOY-FOLDER\ncd ~/BARE-DEPLOY-FOLDER\ngit -init --bare PROJECT-NAME.git\n\nBARE-DEPLOY-FOLDER: Dossier dans lequel il contiendra uniquement votre dossier .git de votre projet\nPROJECT-NAME: nom de votre projet\n```\n\n## 3. Configurer Nginx\n\n\nDans le cas de mon projet Vue on doit mettre en place un reverse proxy dans la configuration nginx sur le port 8080\n\n```\nserver {\n        server_name DOMAINE-NAME;\n        location / {\n                proxy_pass http://localhost:8080;\n                proxy_http_version 1.1;\n                proxy_set_header Upgrade $http_upgrade;\n                proxy_set_header Connection 'upgrade';\n                proxy_set_header Host $host;\n                proxy_cache_bypass $http_upgrade;\n}\n```\n\n## 4. Création du script de deploiment\n\n\nCréation du fichier \"post-receive\" dans le dossier hooks du PROJECT.git qui s'éxecutera à chaque push\n\n```\nsudo vi BARE-DEPLOY-FOLDER/PROJECT-NAME.git/hooks/post-receive\n```\n\nLe script à mettre pour la vue app  : \n\n```\n#!/bin/bash\nTARGET=\"DEPLOY-FOLDER\"\nGIT_DIR=\"BARE-REPOSITORY-FOLDER/PROJECT-NAME.git\"\nBRANCHE=\"BRANCH-TO-DEPLOY\"\nwhile read oldrev newrev ref\ndo\n        if [[ $ref = refs/heads/$BRANCHE ]];\n        then\n                echo \"Ref $ref received. Deploying ${BRANCHE} branch to preprod...\"\n                git --work-tree=$TARGET --git-dir=$GIT_DIR checkout $BRANCHE -f\n                pm2 stop front\n                cd $TARGET\n                npm install\n                npm run build\n                pm2 start front\n\n        else\n                echo \"Ref $ref received. Doing nothing: only the ${BRANCHE} branch may be deployed on this server.\"\n        fi\ndone\n\nDEPLOY-FOLDER: dossier de déploiement crée à l'étape 1\nBARE-REPOSITORY-FOLDER: dossier du repository crée à l'étape 2\nPROJECT-NAME: nom du projet crée à l'étape 2\nBRANCH-TO-DEPLOY: la branch de déploiement (en prod par exemple: master)\n```\n\nLe script à mettre pour servir juste une app servie des fichiers  : \n\n```\n#!/bin/bash\nTARGET=\"DEPLOY-FOLDER\"\nGIT_DIR=\"BARE-REPOSITORY-FOLDER/PROJECT-NAME.git\"\nBRANCHE=\"BRANCH-TO-DEPLOY\"\nwhile read oldrev newrev ref\ndo\n        if [[ $ref = refs/heads/$BRANCHE ]];\n        then\n                echo \"Ref $ref received. Deploying ${BRANCHE} branch to preprod...\"\n                git --work-tree=$TARGET --git-dir=$GIT_DIR checkout $BRANCHE -f\n                sudo chown www-data:www-data -R $TARGET\n\n        else\n                echo \"Ref $ref received. Doing nothing: only the ${BRANCHE} branch may be deployed on this server.\"\n        fi\ndone\n\nDEPLOY-FOLDER: dossier de déploiement crée à l'étape 1\nBARE-REPOSITORY-FOLDER: dossier du repository crée à l'étape 2\nPROJECT-NAME: nom du projet crée à l'étape 2\nBRANCH-TO-DEPLOY: la branch de déploiement (en prod par exemple: master)\n```\n\n## 5. Mise en place de l'app avec pm2\n\n\nEtant donnée qu'une Vue app est lancée sur un port il est primordial d'utiliser pm2 pour faire tourner la Vue app en tache de fond afin de la servir avec Nginx\n- Transférer ou cloner votre application dans votre server distant avec rsync ou un repository git déjà existant\n- Lancer l'app en tache de fond \n\n```\ncd DEPLOY-FOLDER\nnpm i \nnpm run build\npm2 start \"npm run serve\" --name app\n```\n\nLa Vue app tourne maintenant en production sur le domaine spécifier dans ma conf nginx\nIl nous reste juste à ajouter notre git remote pour mettre en place le continious deploiment\n\n## 6. Ajouter le remote du repository du server distant dans le projet local\n\n\nUne fois le script mise en place dans le server distant, nous allons ajouter le git remote à notre projet local\nSi votre server nécessite pas de clé ssh spécial et votre clé public est déjà enregistré dans votre server\n\n```\n git remote add production USER@SERVER-HOST:/PATH/TO/BARE-DEPLOY-SERVER/PROJECT.git\n```\n\nSi votre server nécessite une clée ssh spécial comme une clé .pem avec AWS ec2, vous devez d'abord ajouter votre clée public dans vos authorized_keys avec cette commande :\n\n```\ncat ~/.ssh/id_?sa.pub | ssh -i awsKey.pem ubuntu@EC2-PUBLIC-IP \"cat \u003e\u003e .ssh/authorized_keys\"\n```\n\nUne fois l'accès ssh possible avec votre clé public enregisté, vous pouvez ajouter le git remote comme un server lambda :\n\n```\ngit remote add prod USER@SERVER-HOST:/PATH/TO/BARE-DEPLOY-SERVER/PROJECT.git\n```\n\n## 6. Tenter de deployer\n\n```\ngit push prod master\n```\n\n\n[source](https://gist.github.com/noelboss/3fe13927025b89757f8fb12e9066f2fa#file-git-deployment-md)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimpsdc%2Fcontinious-developement-git","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimpsdc%2Fcontinious-developement-git","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimpsdc%2Fcontinious-developement-git/lists"}