sh git push deployment - 保留目标权限

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh git push deployment - 保留目标权限相关的知识,希望对你有一定的参考价值。

#!/usr/bin/env bash
AS_USER=username
FROM=/path/to/source/*
TO=/path/to/destination
sudo -u $AS_USER rsync -av $FROM $TO

# NOTE: for copy-as-user.sh to work without password you need to add /etc/sudoers.d/repositoryname file with something like this
# `gituser ALL=(www-data) NOPASSWD: /path/to/copy-as-user.sh`
# where gituser is the user preforming the push

# use this as a part of post-recieve hook if you need to retain some permissions eg. copying to webroot
# 1. Force checkout working tree from a bare repository
#   `git --work-tree=/web/root/src --git-dir=/bare/repository.git checkout -f`
# 2. Build/generate/compile/pack files into a static site & copy theme to the web root
#   `cd /web/root/src && npm install && npm run generate && /path/to/copy-as-user.sh`

以上是关于sh git push deployment - 保留目标权限的主要内容,如果未能解决你的问题,请参考以下文章

sh 当git autodeploy脚本与字符串“[deploy]”匹配时

sh 当git autodeploy脚本与字符串“[deploy]”匹配时

sh [git pull / push] pull或push命令#git #bash #linux

sh git init push

sh Git commit&push

sh git hard reset y push