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."
|
description = "Network of activists, researchers and practitioners against the criminalisation of solidarity & for a common care infrastructure."
|
||||||
images = ["/images/piratecaqre.png"]
|
images = ["/images/piratecaqre.png"]
|
||||||
title = "Pirate Care Syllabus"
|
title = "Pirate Care Syllabus"
|
||||||
|
giturl = "https://git.memoryoftheworld.org/PirateCare/Syllabus"
|
||||||
home = "syllabus"
|
home = "syllabus"
|
||||||
|
|
||||||
[outputFormats]
|
[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" \
|
--git_repo "D:\dev\websites\pirate-care-syllabus\gitea\gitea-repositories\gitea\pirate-care-syllabus.git" \
|
||||||
--website "D:\dev\websites\testing-ground\sandpoints" \
|
--website "D:\dev\websites\testing-ground\sandpoints" \
|
||||||
--website_preview "D:\dev\websites\testing-ground\sandpoints\_preview" \
|
--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" \
|
--library "D:\dev\websites\pirate-care-syllabus\_library" \
|
||||||
--tmp_dir "D:\tmp\tmp"
|
--tmp_dir "D:\tmp\tmp"
|
||||||
--oldrev $oldrev \
|
--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"
|
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 os
|
||||||
import argparse
|
import argparse
|
||||||
|
@ -48,6 +52,7 @@ vars = {
|
||||||
'hugo_path': 'hugo',
|
'hugo_path': 'hugo',
|
||||||
'tmp_dir': '/tmp',
|
'tmp_dir': '/tmp',
|
||||||
'force': False,
|
'force': False,
|
||||||
|
'branch': None,
|
||||||
}
|
}
|
||||||
|
|
||||||
# logging time
|
# logging time
|
||||||
|
@ -98,10 +103,14 @@ def clobber(filepath, data, append=False):
|
||||||
f.write(data)
|
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 """
|
""" builds the website to "dest" using "tmp" as an intermediate location """
|
||||||
global GIT_PATH, GIT_REPO, HUGO_PATH
|
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)
|
rmrf(dest)
|
||||||
try:
|
try:
|
||||||
os.makedirs(dest, exist_ok=True)
|
os.makedirs(dest, exist_ok=True)
|
||||||
|
@ -156,7 +165,10 @@ if not published:
|
||||||
if r == "!publish!":
|
if r == "!publish!":
|
||||||
build_site(WEBSITE, TMP_WEBSITE)
|
build_site(WEBSITE, TMP_WEBSITE)
|
||||||
published = True
|
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
|
# 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
|
# @TODO: link the library
|
Loading…
Reference in New Issue