Allow previewing git branches in post receive python script; also local vs prod config
This commit is contained in:
parent
f186abf1ba
commit
cdd8980adb
|
@ -0,0 +1,27 @@
|
|||
baseURL = "http://localhost:8000"
|
||||
languageCode = "en-us"
|
||||
title = "Pirate Care"
|
||||
theme = "sandpoints"
|
||||
relativeurls = true
|
||||
disableKinds = ["RSS", "sitemap"]
|
||||
|
||||
[params]
|
||||
description = "Network of activists, researchers and practitioners against the criminalisation of solidarity & for a common care infrastructure."
|
||||
images = ["/images/piratecaqre.png"]
|
||||
title = "Pirate Care Syllabus"
|
||||
giturl = "http://localhost:3000/gitea/pirate-care-syllabus"
|
||||
home = "syllabus"
|
||||
|
||||
[outputFormats]
|
||||
[outputFormats.js]
|
||||
isPlainText = true
|
||||
mediaType = "application/javascript"
|
||||
|
||||
[outputs]
|
||||
list = ["html", "js"]
|
||||
|
||||
[markup]
|
||||
[markup.tableOfContents]
|
||||
endLevel=4
|
||||
ordered = true
|
||||
startLevel = 1
|
|
@ -9,6 +9,7 @@ disableKinds = ["RSS", "sitemap"]
|
|||
description = "Network of activists, researchers and practitioners against the criminalisation of solidarity & for a common care infrastructure."
|
||||
images = ["/images/piratecaqre.png"]
|
||||
title = "Pirate Care Syllabus"
|
||||
giturl = "https://git.memoryoftheworld.org/PirateCare/Syllabus"
|
||||
home = "syllabus"
|
||||
|
||||
[outputFormats]
|
||||
|
|
|
@ -9,7 +9,7 @@ python "D:\dev\websites\sandpoints-dev\custom_syadmin\git_hooks_post-receive.py"
|
|||
--git_repo "D:\dev\websites\pirate-care-syllabus\gitea\gitea-repositories\gitea\pirate-care-syllabus.git" \
|
||||
--website "D:\dev\websites\testing-ground\sandpoints" \
|
||||
--website_preview "D:\dev\websites\testing-ground\sandpoints\_preview" \
|
||||
--hugo_preview_url https://syllabus.pirate.care/_preview/ \
|
||||
--hugo_preview_url http://localhost:8000/_preview/ \
|
||||
--library "D:\dev\websites\pirate-care-syllabus\_library" \
|
||||
--tmp_dir "D:\tmp\tmp"
|
||||
--oldrev $oldrev \
|
||||
|
@ -20,6 +20,10 @@ To test this script from the command line without relying on a commit hook being
|
|||
|
||||
python "D:\dev\websites\sandpoints-dev\custom_syadmin\git_hooks_post-receive.py" --ref refs/heads/master --git_repo "D:\dev\websites\pirate-care-syllabus\gitea\gitea-repositories\gitea\pirate-care-syllabus.git" --website D:\\dev\\websites\\testing-ground\\sandpoints --website_preview D:\\dev\\websites\\testing-ground\\sandpoints\\_preview --tmp_dir D:\\tmp\\tmp --git_url "http://localhost:3000/gitea/pirate-care-syllabus" --base_url "http://localhost:8000"
|
||||
|
||||
Just a mental note to read refs from the post-receive hook like this:
|
||||
|
||||
oldrev,newrev,refname = sys.stdin.readline().strip().split(’ ‘)
|
||||
|
||||
"""
|
||||
import os
|
||||
import argparse
|
||||
|
@ -48,6 +52,7 @@ vars = {
|
|||
'hugo_path': 'hugo',
|
||||
'tmp_dir': '/tmp',
|
||||
'force': False,
|
||||
'branch': None,
|
||||
}
|
||||
|
||||
# logging time
|
||||
|
@ -98,10 +103,14 @@ def clobber(filepath, data, append=False):
|
|||
f.write(data)
|
||||
|
||||
|
||||
def build_site(dest, tmp, hugo_environment='gitea'):
|
||||
def build_site(dest, tmp, branch=None, hugo_environment='gitea'):
|
||||
""" builds the website to "dest" using "tmp" as an intermediate location """
|
||||
global GIT_PATH, GIT_REPO, HUGO_PATH
|
||||
cmd([GIT_PATH, 'clone', '.', tmp], cwd=GIT_REPO)
|
||||
if branch:
|
||||
print("Cloning branch: ", branch)
|
||||
cmd([GIT_PATH, 'clone', '--single-branch', '--branch', branch, '.', tmp], cwd=GIT_REPO)
|
||||
else:
|
||||
cmd([GIT_PATH, 'clone', '.', tmp], cwd=GIT_REPO)
|
||||
rmrf(dest)
|
||||
try:
|
||||
os.makedirs(dest, exist_ok=True)
|
||||
|
@ -156,7 +165,10 @@ if not published:
|
|||
if r == "!publish!":
|
||||
build_site(WEBSITE, TMP_WEBSITE)
|
||||
published = True
|
||||
# Let the world know if there hasn't been a publish
|
||||
if not published:
|
||||
print("The site wasn't build because there was no publish trigger, nor was it forced.")
|
||||
# create preview version
|
||||
build_site(WEBSITE_PREVIEW, TMP_WEBSITE_PREVIEW, hugo_environment='preview')
|
||||
build_site(WEBSITE_PREVIEW, TMP_WEBSITE_PREVIEW, branch=BRANCH, hugo_environment='preview')
|
||||
|
||||
# @TODO: link the library
|
Loading…
Reference in New Issue