Git Deployment: Difference between revisions
From charlesreid1
(Created page with "To use git for static content deployment: * Use the <code>gh-pages</code> branch to hold all of the web content * Use the <code>master</code> or <code>source</code> branch to...") |
No edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 3: | Line 3: | ||
* Use the <code>gh-pages</code> branch to hold all of the web content | * Use the <code>gh-pages</code> branch to hold all of the web content | ||
* Use the <code>master</code> or <code>source</code> branch to hold the files needed to generate the static content | * Use the <code>master</code> or <code>source</code> branch to hold the files needed to generate the static content | ||
==New Deployment== | |||
When you have content on your <code>gh-pages</code> branch, deploy it on your live machine using the following git clone command: | When you have content on your <code>gh-pages</code> branch, deploy it on your live machine using the following git clone command: | ||
| Line 24: | Line 26: | ||
I also like to clone a copy of the source next to htdocs and git, so that <code>/www/example.com/example.com-src</code> is a copy of the master or source branch. | I also like to clone a copy of the source next to htdocs and git, so that <code>/www/example.com/example.com-src</code> is a copy of the master or source branch. | ||
==Pulling Existing Deployment== | |||
Once you've updated content on the <code>gh-pages</code> branch, you can run git pull in the same manner as the git clone command above (that is, specifying a different git and working directory). However, the syntax looks different: | |||
<pre> | |||
git -C /www/example.com --git-dir=git --work-tree=htdocs pull origin gh-pages | |||
</pre> | |||
==Webhooks== | |||
You can add these to webhook scripts, as with Captain Hook. | |||
* Captain Hook documentation: https://pages.charlesreid1.com/b-captain-hook | |||
* Captain Hook source code: https://git.charlesreid1.com/bots/b-captain-hook | |||
==Flags== | |||
[[Category:Git]] | [[Category:Git]] | ||
Latest revision as of 08:34, 29 April 2018
To use git for static content deployment:
- Use the
gh-pagesbranch to hold all of the web content - Use the
masterorsourcebranch to hold the files needed to generate the static content
New Deployment
When you have content on your gh-pages branch, deploy it on your live machine using the following git clone command:
git -C /www/example.com clone --separate-git-dir=git -b gh-pages <git-repo-url> htdocs
This will create the following directory structure:
/www/example.com/
htdocs/
index.html
...
git/
...
This keeps your .git out of your htdocs directory.
I also like to clone a copy of the source next to htdocs and git, so that /www/example.com/example.com-src is a copy of the master or source branch.
Pulling Existing Deployment
Once you've updated content on the gh-pages branch, you can run git pull in the same manner as the git clone command above (that is, specifying a different git and working directory). However, the syntax looks different:
git -C /www/example.com --git-dir=git --work-tree=htdocs pull origin gh-pages
Webhooks
You can add these to webhook scripts, as with Captain Hook.
- Captain Hook documentation: https://pages.charlesreid1.com/b-captain-hook
- Captain Hook source code: https://git.charlesreid1.com/bots/b-captain-hook